P13585 [CodeChef] iitk2p06
NOI
题目描述

You are given e even and o odd numbers. In a single operation, you change an even to odd number or vice versa. Find out min number of operations needed to
do such that ratio of even to odd numbers becomes 2 : 3. If it is impossible to do so, output -1.

Input

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
For each test case, there will be a single line of input containing two space separated integers e and o.

Output

For each test case, output a single line containing a single integer corresponding to the answer of the problem.

Constraints

1 ≤ T ≤ 10^5
1 ≤ e, o ≤ 10^9

Example
Input:
3
2 3
3 2
3 3
Output:
0
1
-1

Explanation
Example case 1. Ratio of even : odd numbers are already 2 : 3. So no need of any operation.
Example case 2. Change one even to odd, you will have 2 even and 3 odd satisfying the ratio. So only 1 operation is needed.
Example case 3. There is no way of doing operations which could make desired ratio.

输入格式

见题面

输出格式

见题面

样例输入
3 2 3 3 2 3 3
样例输出
0 1 -1