Codeforces Round 1093 (Div. 1)
A
Grid L
Codeforces
1400
原题
←B1 →
翻译中…

Roger has $p$ unit-length segments and $q$ L-shaped pieces, each formed by joining two unit-length segments at a right angle.

翻译中…

image

翻译中…

He wants to use all of these pieces, with no piece left unused, to form a grid of dimensions $n \times m$.

翻译中…

Given $p$ and $q$, determine whether there exist positive integers $n$ and $m$ such that an $n \times m$ grid can be formed using exactly $p$ unit-length segments and $q$ L-shaped pieces, possibly rotating them, and provide any valid $n$ and $m$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). The description of the test cases follows.

翻译中…

The first line of each test case contains two integers $p$ and $q$ ($1 \le p, q \le 10^8$).

翻译中…

Output

翻译中…

For each test case, print any valid $n$ and $m$ such that it's possible to construct $n \times m$ using all pieces. If there are no such $n$ and $m$, print $-1$.

翻译中…

Note

翻译中…

Here are the constructions for examples 2, 3, and 4. We use a different color for different L-shaped pieces, black for all unit-length segments.

翻译中…

image

翻译中…

样例

Input #1
7
1 2
1 3
5 1
2 5
2 10
100000000 100000000
1 1
Output #1
-1
1 2
1 2
2 2
2 4
-1
-1
InputCopy OutputCopy
题目信息
题号
2219A
时间限制
2 s
内存限制
256 MB
标签
暴力
构造
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。