#JSUTFPC2025I. Bitwise Operation——位运算
Bitwise Operation——位运算
Statement
Timothy is a young computer scientist who has recently been exploring the fascinating properties of binary arithmetic. While organizing some old manuscripts left by his grandfather, he stumbled upon a mysterious mathematical formula:
Here, represents the "balanced number", and the bitwise operators and represent bitwise AND and bitwise OR operations, respectively. In mainstream programming languages, & is used to represent bitwise AND, for example, int c = a \& b is represented as , and bitwise OR is similarly represented.
To be precise, the bitwise AND operator follows this rule: the result bit is 1 only when both corresponding binary bits are 1; otherwise, it is 0. For example, consider calculating (the lower right corner indicates the base 10 or base 2)
$$5_{(10)}\ \&\ 9_{(10)} = 0101_{(2)}\ \&\ 1001_{(2)}=0001_{(2)}=1_{(10)} $$Similarly, bitwise OR means that when at least one of the two corresponding bits is 1, the result bit is 1; otherwise, it is 0.
Timothy speculated that this formula might hide some kind of symmetry in binary bit operations. If he could find the smallest positive integer that satisfies the condition, he would be able to unlock the next password in the notebook.
However, not all pairs of and can find a corresponding . If no such exists, it indicates that this has no affinity with the "balanced number", and a return value of is required.
Please help Timothy write a program to find the smallest positive integer for a given and , or determine if it does not exist.
Input
The input contains a line with two integer numbers representing and respectively, where and they are separated by a space.
Output
It contains an integer representing .
Samples
114514 1919810
1805296
1919810 114514
-1