409225: GYM103463 E The King Of Sum Xor

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. The King Of Sum Xortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

If you have solved CrossFire #6XX (Div.998244353) D, you will have the potential to become the king of sum xor.

Today Dup4 meets a problem and he asks you for help. He wants to know whether there exists an array $$$n$$$ non-negative integers $$$a_1, a_2, \cdots ,a_n$$$(the array can be empty) that follow these rules.

  • $$$\displaystyle a_1+a_2+\cdots +a_n = S$$$
  • $$$\displaystyle a_1 \oplus a_2 \oplus \cdots \oplus a_n = X$$$(Here $$$\oplus$$$ denotes bitwise xor operation)

However, Dup4 thinks the problem is so easy. He thinks he needs to change something.

  1. He constructs all arrays that satisfying the requirements.
  2. He defines the maximum value of the $$$i$$$-th array as $$$M_i$$$.
  3. He finds the minimum $$$M_i$$$ of the all arrays as $$$MIN$$$.
  4. He defines a set $$$V$$$ to be composed of arrays which satisfying the condition of $$$M_i = MIN$$$.

Finally, He wants to know the minimum $$$n$$$(the length of the array) of the $$$V$$$.

Input

There are several test cases.

The first line contains a single integer $$$T(1 \leq T \leq 10^2)$$$, denoting the number of test cases. Then follow all the test cases.

For each test case, the first line contains two integers $$$s$$$, $$$x$$$ $$$(0 \leq s, x \le 2^{60} - 1)$$$.

Output

For each test case, print $$$-1$$$ if there doesn't exist an array with the mentioned property else print your answer.

ExampleInput
2
9 3
19 1
Output
6
19

加入题单

上一题 下一题 算法标签: