Consider two integers, and
. There are two operations which you can perform any number of times:
- Set
to
.
- Set
to
OR
.
For each of the test cases, you must calculate the fewest operations needed to make
equal to
or determine that no such sequence of operations exists.
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Input Specification
The first line contains an integer, , the number of test cases.
Each of the next lines contains two space-separated integers,
and
.
Output Specification
For each test case, on its own line, output the fewest operations needed to make equal to
. If no sequence of operations exists, output
-1
instead.
Sample Input
2
1 2
3 6
Sample Output
1
2
Comments