409139: GYM103446 D Strange Fractions

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Strange Fractionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Given a positive fraction $$$\frac{p}{q}$$$, you should find two positive integers $$$a,b$$$ that $$$\frac{p}{q} = \frac{a}{b} + \frac{b}{a}$$$. If no such integers, report it.

Input

The first line contains one integer $$$T\,(1\le T \le 10^5)$$$, denoting the number of test cases.

For each test case:

Input one line containing two integers $$$p,q\,(1\le p,q \le 10^7)$$$, denoting the given fraction.

Output

For each test case:

If solution exists, output one line containing two integers $$$a,b\,(1\le a,b \le 10^9)$$$, or print two zeros in one line if no solution.

ExampleInput
2
5 2
5 1
Output
1 2
0 0
Note

For the first case, $$$\frac{5}{2} = \frac{1}{2} + \frac{2}{1}$$$ holds. So one possible solution is $$$a=1,b=2$$$.

加入题单

算法标签: