CF2114A.Square Year

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Square Year

One can notice the following remarkable mathematical fact: the number 20252025 can be represented as (20+25)2(20+25)^2.

You are given a year represented by a string ss, consisting of exactly 44 characters. Thus, leading zeros are allowed in the year representation. For example, "0001", "0185", "1375" are valid year representations. You need to express it in the form (a+b)2(a + b)^2, where aa and bb are non-negative integers, or determine that it is impossible.

For example, if ss = "0001", you can choose a=0a = 0, b=1b = 1, and write the year as (0+1)2=1(0 + 1)^2 = 1.

Input

The first line of the input contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The following lines describe the test cases.

The only line of each test case contains a string ss, consisting of exactly 44 characters. Each character is a digit from 00 to 99.

Output

On a separate line for each test case, output:

  • Two numbers aa and bb (a,b0a, b \ge 0) such that (a+b)2=s(a + b)^2 = s, if they exist. If there are multiple suitable pairs, you may output any of them.
  • The number 1-1 otherwise.

Samples

5
0001
1001
1000
4900
2025
0 1
-1
-1
34 36
20 25

在线编程 IDE

建议全屏模式获得最佳体验