Problem F: Mex Problem

Problem F: Mex Problem

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 110  Solved: 37
[Submit][Status][Web Board]

Description

\(\hspace{1.2em}\)Here are \(t(1 \leq t \leq 10^5)\) tests, each test contains two integers \(a(0 \leq a \leq 10^9)\) and \(b(0 \leq b \leq 10^9)\), you should find the Mex of the sequence \(a\oplus0\), \(a\oplus1\)... \(a\oplus b\), here \(\oplus\) mean the bitwise xor operation.the Mex of the sequence of non-negative integers is the smallest non-negative integer that doesn't appear in this sequence. For example, Mex(1,2,3)=0,Mex(0,1,2,4,5)=3

Input

The first line contains a single integer  \(t(1 \le t \le 10^5)\), indicates the number of test cases.
The first and only line of each test case contains two integers a and b \((0\leq a,b\leq 10^9)\).

Output

For each test case, print a line contains a single integer  — the answer to the problem.

Sample Input

3
0 9
8 6
9 9

Sample Output

10
0
2

HINT

[Submit][Status]