ozos-equations-1

Ozo is making a project on mathematical equation given by his teacher, but he want to test the given equation,
whether this equation contain any positive integral root or not. Because if equation does not contain integral root his project will give abnormal results and he will not able to submit his project on time.

                     Equation:   x^2 = N - Bx

where N is an integer, B is sum of digits of number x. Your task is to find smallest positive integral root of this equation.

INPUT

First line of Input contains no. of test cases T. Each test case contain "N".

OUTPUT

For each test case output smallest positive integral root of the equation or print -1 if there is no positive integral roots.

CONSTRAINTS

T ≤ 10^5

1 ≤ N ≤ 8 * 10^18

SAMPLE INPUT
2
2
4

SAMPLE OUTPUT
1
-1

Source: hackerearth | Difficulty: MEDIUM
Tags: Mathematics


Solutions: