Codeforces Round 1048 (Div. 2)
A
Maple and Multiplication
Codeforces
800
原题
←B →
翻译中…

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

翻译中…
  • Choose any positive integer $x$, and multiply either $a$ or $b$ by $x$.
翻译中…

Your task is to determine the minimum number of operations required to make $a$ equal to $b$. 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 $t$ ($1 \le t \le 100$). The description of the test cases follows.

翻译中…

The first and only line of each test case contains two positive integers $a$ and $b$ ($1 \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 $a$ equal to $b$.

翻译中…

Note

翻译中…

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

翻译中…

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

翻译中…

In the third test case, $a$ and $b$ are already equal, so no operations are required.

翻译中…

样例

Input #1
3
1 2
10 3
1000 1000
Output #1
1
2
0
InputCopy OutputCopy
题目信息
题号
2139A
时间限制
1 s
内存限制
256 MB
标签
贪心
数学

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