First Occurrence

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

The famous Thue-Morse sequence T=t_0t_1t_2T = t\_0 t\_1 t\_2 \ldots is an infinite binary sequence that can be defined as follows: if the number of ones in the binary representation of nn is odd then t_n=1t\_n = 1, otherwise t_n=0t\_n = 0.

The sequence starts with 01101001100101101001011001101001...

Consider a substring of this sequence t_l..r=t_lt_l+1t_rt\_{l..r} = t\_l t\_{l+1} \ldots t\_r. Find the index of the first occurrence of t_l..rt\_{l..r} in TT. In other words, find the smallest non-negative integer ii such that t_l..r=t_i..i+(rl)t\_{l..r} = t\_{i..i+(r-l)}.

입력

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1051 \le t \le 10^5). Description of the test cases follows.

The only line of each test case contains two integers ll and rr (0lr10180 \le l \le r \le 10^{18}).

출력

For each test case, print the index of the first occurrence of t_l..rt\_{l..r} in TT.

힌트

In the first example test case, t_0..10t\_{0..10} obviously first occurs in TT at index 00.

In the second example test case, t_13..13=t\_{13..13} = 1 first occurs in TT at index 11.

In the third example test case, t_23..27=t\_{23..27} = 00110 first occurs in TT at index 55.