本场比赛其他题目的题解
A. Domino Disaster
B. MEXor Mixup
C. Carrying Conundrum
D. Expression Evaluation Error
E. Non-Decreasing Dilemma
B. MEXor Mixup
题目描述
Alice gave Bob two integers a a a and b b b ( a > 0 a > 0 a>0 and b ≥ 0 b \ge 0 b≥0). Being a curious boy, Bob wrote down an array of non-negative integers with MEX \operatorname{MEX} MEX value of all elements equal to a a a and XOR \operatorname{XOR} XOR value of all elements equal to b b b.
What is the shortest possible length of the array Bob wrote?
Recall that the MEX \operatorname{MEX} MEX () of an array is the minimum non-negative integer that does not belong to the array and the XOR \operatorname{XOR} XOR of an array is the bitwise XOR of all the elements of the array.
Input
The input consists of multiple test cases. The first line contains an integer t t t ( 1 ≤ t ≤ 5 ⋅ 1 0 4 1 \leq t \leq 5 \cdot 10^4 1≤t≤5⋅104) — the number of test cases. The description of the test cases follows.
The only line of each test case contains two integers a a a and b b b ( 1 ≤ a ≤ 3 ⋅ 1 0 5 1 \leq a \leq 3 \cdot 10^5 1≤a≤3⋅105; 0 ≤ b ≤ 3 ⋅ 1 0 5 0 \leq b \leq 3 \cdot 10^5 0≤b≤3⋅105) — the MEX \operatorname{MEX} MEX and XOR \operatorname{XOR} XOR of the array, respectively.
Output
For each test case, output one (positive) integer — the length of the shortest array with MEX \operatorname{MEX} MEX a