Time limit: 2s
Memory limit: 256MB
Input:
Output:
An interval is a giga-xor interval if and only if the xor sum of the natural numbers inside the interval is equal to , where and are natural numbers.
Strictly speaking, an interval is giga-xor if and only if .
You are given pairs of numbers . For each pair, you need to find the length of the shortest interval such that and is a giga-xor interval.
Input
The first line contains (), the number of pairs.
On the following lines, there are integers , ().
For tests worth points,
For tests worth more points,
Output
Print on lines, the answer for each pair.
Example
stdin
5
4 5
2 3
1 7
8 8
1 10
stdout
4
3
7
4
11