#Qua2204. Game Theory
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
相关
在下列比赛中: