## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Reduce to zero CodeChef Solution | CodeChef Problem Solution 2022

Chef has two integers $X$ and $Y$. Chef wants to perform some operations to make both $X$ and $Y$ zero simultaneously. In one operation, Chef can either:

• set $X:=2\cdot X$
• or set $Y:=2\cdot Y$
• or set $X:=X-1$ and $Y:=Y-1$

Chef is a little busy with preparing the contest. Help him find the minimum number of operations required to make both $X$ and $Y$ equal to $0$ simultaneously. If it is impossible to do so after any

number of operations, print $-1$.

### Input Format

• The first line contains a single integer $T$ — the number of test cases. Then the test cases follow.

• The first and only line of each test case contains two space separated integers $X$ and $Y$.

### Output Format

For each test case, print the minimum number of operations required to make $X$ and $Y$ zero simultaneously. If it is impossible to do so after any number of operations, print $-1$ instead.

### Constraints

• $1\le T\le 3\cdot {10}^{}$