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.
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
The first line contains an integer, , the number of test cases.
Each of the next lines contains two space-separated integers, and .
For each test case, on its own line, output the fewest operations needed to make equal to . If no sequence of operations exists, output
2 1 2 3 6