Ankit was recently solving problems on an online judge, he came across a question that seemed easy but Ankit was not able to solve it. He was very sad regarding this. Ankit and Sintu were teammates for an upcoming programming competition and were practicing together. Ankit took the task to Sintu and now they worked out like a team and Bamm! they found the solution.
The problem is as follows, given t test cases, each test case will have two integers n and m. You can perform two types of operations :-
- Subtract 1 from n
- Multiply n with 2
Now the task is simple you have to find the minimum number of operations required to convert n to m and for each test case print the answer on a new line.
Constraints :-
1 <= t <= 105
1 <= n,m <= 104
Sample Input :-
2
4 6
10 1
Sample Output :-
2
9
Problem Author :- Sintu Kumar , Ankit Raj