Problem G
Guess the Number!
Input: Standard Input
Output: Standard Output

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'm not too bad at math, so 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).

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 can be found. Otherwise, print -1 in the corresponding line.

Sample Input

3
64
3225
387420489

Sample Output

4
-1
9
__________________________________________________________________________________________
Rujia Liu