Game Theory
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description
Libra and Rahn are playing a game.
Libra has a non-negative integer and Rahn has a non-negative integer . Libra wants to take several steps to change to . Each step Libra can take one of the following operations:
- Add to ().
- Multiply by ().
- Divide by (). Note that Libra can take this operation only if is even.
Libra wants to know the minimum steps to change to using the operations above.
Format
Input
The first line contains one integer -- the number of test cases.
For each test case there is a single line contains two integers .
Output
For each test case, output a line with an integer representing the minimum steps Libra needs to take.
Samples
6
31 13
12 8
25 6
10 24
1 1
997 120
8
3
8
3
0
20