CF1674A.Number Transformation

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

Number Transformation

You are given two integers xx and yy. You want to choose two strictly positive (greater than zero) integers aa and bb, and then apply the following operation to xx exactly aa times: replace xx with bxb \cdot x.

You want to find two positive integers aa and bb such that xx becomes equal to yy after this process. If there are multiple possible pairs, you can choose any of them. If there is no such pair, report it.

For example:

  • if x=3x = 3 and y=75y = 75, you may choose a=2a = 2 and b=5b = 5, so that xx becomes equal to 355=753 \cdot 5 \cdot 5 = 75;
  • if x=100x = 100 and y=100y = 100, you may choose a=3a = 3 and b=1b = 1, so that xx becomes equal to 100111=100100 \cdot 1 \cdot 1 \cdot 1 = 100;
  • if x=42x = 42 and y=13y = 13, there is no answer since you cannot decrease xx with the given operations.

Input

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

Each test case consists of one line containing two integers xx and yy (1x,y1001 \le x, y \le 100).

Output

If it is possible to choose a pair of positive integers aa and bb so that xx becomes yy after the aforementioned process, print these two integers. The integers you print should be not less than 11 and not greater than 10910^9 (it can be shown that if the answer exists, there is a pair of integers aa and bb meeting these constraints). If there are multiple such pairs, print any of them.

If it is impossible to choose a pair of integers aa and bb so that xx becomes yy, print the integer 00 twice.

Samples

3
3 75
100 100
42 13
2 5
3 1
0 0

在线编程 IDE

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