A. Max Xor Pair
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Sanjay gives you two integers $$$N$$$ and $$$X$$$, find the maximum Bitwise Xor value of a pair of integers in the range $$$[1, N]$$$. However, the chosen pair must not include the integer $$$X$$$.

You need to determine the maximum Bitwise Xor value achievable by choosing two distinct numbers $$$a$$$ and $$$b$$$ $$$(1 \leq a, b \leq N, a \neq X , b \neq X, a \neq b)$$$

Input
  • The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^5)$$$ — the number of test cases.
  • For each test case:
    • The first line contains two integers $$$N$$$ and $$$X$$$ $$$(3 \leq N \leq 10^9, 1 \leq X \leq 10^9)$$$.
Output
  • For each test case, print a single integer — the maximum Bitwise Xor value satisfying the given conditions.
Example
Input
2
6 1
6 2
Output
7
7
Note
  • For test case $$$1$$$, the pair $$$(2,5)$$$ achieves the maximum Bitwise Xor value of $$$7$$$.
  • For test case $$$2$$$, the pair $$$(1,6)$$$ achieves the maximum Bitwise Xor value of $$$7$$$.