## Magic Bits

View as PDF

Points: 10 (partial)
Time limit: 2.0s
Memory limit: 256M

Authors:
Problem type

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.

#### 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