Guess the Number!

In this problems, we’ll talk about BIG numbers. Yes, I’m sorry, big numbers again.... Let N be a positive integer, we call S = NN the “big big power” of N. In this time, I will calculate the exact value of S for a positive integer N. Then, I tell you S, you guess N. Note that I may make mistakes in calculating, but I promise that if I’m wrong, my result and the correct result will differ in exactly one single digit, and the number of digits is always correct (no missing or extra digits). That means, I will NOT get ‘terribly wrong result’ such as 3456 or 111. Input The first line in the input contains a positive integer T indicating the number of test cases (1 ≤ T ≤ 10). Each case consists of a single line containing the exact value of S. The line does not contain any character apart from digits (0,1,2,...,9), and will have at most 500,000 digits. Input integers do NOT contain leading zeros. Output For each test case, print on a single line the value of N if a unique N satisfying NN = S can be found. Otherwise, print ‘-1’ in the corresponding line, showing that I made a mistake in calculating. Sample Input 4 3 4 3225 387420489 Sample Output -1 2 -1 9