408495: GYM103150 I X-OR XOR

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

Description

I. X-OR XORtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Given two integers $$$a$$$ and $$$b$$$, find any nonnegative integer $$$x$$$ such that $$$x \text{ OR } a = x \text{ XOR } b$$$, or determine that none exist.

Here $$$\text{OR}$$$ represents the bitwise OR operation and $$$\text{XOR}$$$ represents the bitwise XOR operation.

Input

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases.

The only line of each test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \leq a, b \leq 10^{18}$$$) — the values given.

Output

For each test case, output any nonnegative integer $$$x$$$ ($$$0 \leq x \leq 10^{18}$$$) such that $$$x \text{ OR } a = x \text{ XOR } b$$$. If no such $$$x$$$ exist, output $$$-1$$$.

ExampleInput
7
1 1
10 3
10 12
9 15
15 8
12 1
19 1
Output
0
-1
-1
-1
7
-1
18

加入题单

上一题 下一题 算法标签: