Easy Math > Basic Math

In positional notation we know the position of a digit indicates the weight of that digit toward the value of a number.<br> For example, in the base 10 number 123 we know that 3 has the weight 10^0, 2 has the weight 10^1, and 1 has the weight 10^2 yielding the value `1*10^2 + 2*10^1 + 3*10^0` or just `100 + 20 + 3`. <br> The same mechanism is used for numbers expressed in other bases. While most people assume the numbers they encounter everyday are expressed using base 10, we know that other bases are possible. In particular, the number 123 in base 50 or base 20 represents a totally different value than 123 in base 10.<br> In this problem a non-negative number is given and you have to determine what is the **minimum base** is needed to express the number correctly.The base is **between 2 and 62(inclusive)**.To represent a number the digits 0 through 9 have their usual decimal interpretations. The uppercase alphabetic characters A through Z represent digits with values 10 through 35, respectively.The lowercase alphabetic characters a through z represent digits with values 36 through 61, respectively. For example, if the number is 123 then it is assumed that the base will be between 4 and 62(inclusive). But among this 4 is minimum so the answer will be 4.<br> **Note: Answer always exist between base 2 to 62.** Input: ------ Input starts with an integer **T (1<=T<=100)**, denoting the number of test cases. Each case contains a **very big number** having length at most **1000**. Output: ------- For each case of input, print **Case x: answer** Here x is the test case number and answer is the accepted base. See Sample Input and Output for clarifications. Sample Input ------------ 2 123 abc Sample Output ------------- Case 1: 4 Case 2: 39

Md. Amir-Al-Fahim