定義遞推數列:
a_n= \begin{cases} 0& n=0\\ \left \lfloor \frac{a_{\left \lfloor \frac{n}{2} \right \rfloor}}{2} \right \rfloor\ \lor \ \left ( (n\bmod 2)\times 2 ^{m}\right) & n \geq 1 \end{cases}
其中, \left \lfloor x \right \rfloor 表示向下取整, x \lor \ y 表示整數 x 與 y 按位或後的結果。
對於給定的 m,k ,求 a_k 的值。
Define a recurrence sequce a as follows,
a_n= \begin{cases} 0& n=0\\ \left \lfloor \frac{a_{\left \lfloor \frac{n}{2} \right \rfloor}}{2} \right \rfloor\ \lor \ \left ( (n\bmod 2)\times 2^{m}\right) & n \geq 1 \end{cases}
where \lfloor x \rfloor gives the greatest integer that is less than or equal to x as an output, "\lor" represents the bitwise-or operator.
Please find a_k given m, k .
輸入數據共 T+1 行。
第一行一個整數 T ,表示數據組數。接下來 T 行,每行兩個整數 m,k ,含義如題面所示。
The input contains many test cases. The first line of the input contains an integer T , indicating the number of test cases.
In the following T lines, each line contains two integers m and k , separated by a space, the meanings of which are as shown above.
共 T 行,每一行一個整數,分別表示每組數據的答案。
Write T lines in total; each line of the output contains an integer, indicating the answer to the corresponding test case, i.e., a_k .
2 10 0 2 3
0 6
對於第一組樣例: a_0=0 ,
對於第二組樣例: a_0=0,a_1=4,a_2=2,a_3=6 。
In the first test case, a_0=0 .
In the second test case, a_0=0,a_1=4,a_2=2,a_3=6 .
對於全部測試數據,滿足 1 \leq T\leq 3\times 10^5,0\leq m\leq 60,0\leq k \leq 2^{m+1} 。
For all test data, 1 \leq T\leq 3\times 10^5,0\leq m\leq 60,0\leq k \leq 2^{m+1} .