There are vertices numbered from through . Choose a non-negative integer and construct an undirected graph by connecting two distinct vertices and with an edge if and only if .
The symbol denotes bitwise XOR. When the two numbers are written in binary, each bit of the result is if the corresponding bits differ and otherwise. For example, .
A connected component is a maximal set of vertices in which any two vertices can reach each other by following edges. An isolated vertex also forms a connected component.
Find the smallest non-negative integer for which the graph has at most connected components.
The input is given in the following format.
For each test case, output the smallest non-negative integer for which the graph has at most connected components, on a separate line. Output the answers in the order the test cases appear in the input.
When , the graph has no edges and therefore has connected components. In each of the first three test cases, , so the answer is . In each remaining test case, .
The first line contains the number of test cases . Each test case is given in the following format.
A single line contains two integers and , separated by a space.