8981: Square

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:3 通过:3

题目描述

Find a number 0≤y≤1090 \leq y\leq 10^90y109 so that the square of yyy starts with xxx in Decimal.
Formally, given a integer xxx, find an integer yyy(0≤y≤1090 \leq y\leq 10^90y109) such that there exists a nonnegative integer kkk that satisfies ⌊y210k⌋=x\lfloor \frac{y^2}{10^k} \rfloor = x10ky2=x.

输入格式


Each test contains multiple test cases. The first line of input contains a single integer ttt(1≤t≤1051\le t\le 10^51t105) --- the number of test cases.
Each test case contains an integer xxx(0≤x≤1090\leq x\leq 10^90x109) - the xxx described in the problem statement.

输出格式


For each test case, output an integer yyy(0≤y≤1090\leq y\leq 10^90y109).If there are multiple results, you can output any one. If no yyy satisfies the condition, output `-1'.

输入样例 复制

3
1
123
781273981

输出样例 复制

4
111
-1

分类标签