10261026 SUSTech Online Judge
Problem 1026 --Cuperman’s Cup Game

1026: Cuperman’s Cup Game

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 267  Solved: 99
[Submit][Status][Web Board]

Description


Cuperman has two cups A and B. There are x balls in A, y balls in B. You can move balls between these two cups. The number of balls can be moved from A to B (or from B to A) is equal to the number of balls in B (or in A). For example, if A has 3 balls and B has 2 balls, you only can move 2 balls from A to B, but cannot move 2 balls from B to A. Now Cuperman wants to know, how many move steps he need to obtain one empty cup.


Input


The first line will be an integer T (T <= 105), which is the number of test cases.

For each test case, you will be given two integers x and y. (0 <= x, y <= 100000)


Output


For each test case, output the number problem required. If you can't make any cup empty, output -1.


Sample Input

2
5 5
3 5

Sample Output

1
3

HINT


Bonus Hard

Source

[Submit][Status]