CF2139A.Maple and Multiplication

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

Maple and Multiplication

Maple has two positive integers aa and bb. She may perform the following operation any number of times (possibly zero) to make aa equal to bb:

  • Choose any positive integer xx, and multiply either aa or bb by xx.

Your task is to determine the minimum number of operations required to make aa equal to bb. It can be proven that this is always possible.

Input

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

The first and only line of each test case contains two positive integers aa and bb (1a,b10001 \le a, b \le 1000) — the numbers Maple currently has.

Output

For each test case, output a single integer representing the minimum number of operations Maple needs to make aa equal to bb.

Note

In the first test case, you can multiply a=1a=1 by 22 to obtain a=b=2a=b=2. This requires one operation.

In the second test case, you can multiply a=10a=10 by 300300 to get a=3000a = 3000, then multiply b=3b=3 by 10001000 to get b=3000b=3000. This requires two operations. Note that the numbers may exceed 10001000 after the operations.

In the third test case, aa and bb are already equal, so no operations are required.

Samples

3
1 2
10 3
1000 1000
1
2
0

在线编程 IDE

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