Problem Statement
You are given positive integers $C$ and $X$ that are less than $2^{30}$.
Determine whether there exists a positive integer $n$ that satisfies all of the following conditions, and if it exists, find one such $n$.
$1\le n < 2^{60}$$(n \oplus C) \bmod n=X$
Here, $n \oplus C$ denotes the bitwise $\mathrm{XOR}$ of $n$ and $C$.
You are given $T$ test cases, solve each of them.
What is bitwise $\mathrm{XOR}$? The bitwise $\mathrm{XOR}$ of non-negative integers $X$ and $Y$, $X \oplus Y$, is defined as follows: When $X \oplus Y$ is written in binary, the digit in the $2^k$ place ($k \geq 0$) is $1$ if exactly one of the digits in the $2^k$ place of $X$ and $Y$ written in binary is $1$, and $0$ otherwise. For example, $3 \oplus 5 = 6$ (in binary: $011 \oplus 101 = 110$).
Constraints
$1\le T\le 2\times 10^5$$1\le C,X < 2^{30}$- All input values are integers.
Input
The input is given from Standard Input in the following format:
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
Each test case is given in the following format:
C X
Output
Output the answers for each test case in order, separated by newlines.
For each test case, if there does not exist an $n$ that satisfies all conditions, print -1.
Otherwise, print $n$ that satisfies all conditions.
If there are multiple $n$ that satisfy all conditions, any of them will be accepted.
样例
3
10 6
2 3
777 153
7
-1
208
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。