CF2219A Grid L

Description

Roger has $ p $ unit-length segments and $ q $ L-shaped pieces, each formed by joining two unit-length segments at a right angle. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2219A/e40719d8c736a96f9c4c1bd8930e75ba63ef467222a195a96fc2235fee4888d7.png)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 Format

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 Format

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 $ .

Explanation/Hint

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. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2219A/ae4195c6815054ee03fe14857702121e14744cab26eaac2c2896411c12fa7ed3.png)