CF BUDDY
← Problems·

1658D1 · 388535 (Easy Version)

1600 · bitmasks, math

Problem: This is the easy version of the problem. The difference in the constraints between both versions is colored below in red. You can make hacks only if all versions of the problem are solved.

Marin and Gojou are playing hide-and-seek with an array.

Gojou initially performs the following steps:

  • First, Gojou chooses 22 integers ll and rr such that lrl \leq r.
  • Then, Gojou makes an array aa of length rl+1r-l+1 which is a permutation of the array [l,l+1,,r][l,l+1,\ldots,r].
  • Finally, Gojou chooses a secret integer xx and sets aia_i to aixa_i \oplus x for all ii (where \oplus denotes the bitwise XOR operation).

Marin is then given the values of l,rl,r and the final array aa. She needs to find the secret integer xx to win. Can you help her?

Note that there may be multiple possible xx that Gojou could have chosen. Marin can find any possible xx that could have resulted in the final value of aa.

Input Format: The first line contains a single integer tt (1t1051 \leq t \leq 10^5) — the number of test cases.

In the first line of each test case contains two integers ll and rr (0=lr<217 \color{red}{\boldsymbol{0} \boldsymbol{=} \boldsymbol{l}} \le r < 2^{17}).

The second line contains rl+1r - l + 1 integers of a1,a2,,arl+1a_1,a_2,\ldots,a_{r-l+1} (0ai<2170 \le a_i < 2^{17}). It is guaranteed that aa can be generated using the steps performed by Gojou.

It is guaranteed that the sum of rl+1r - l + 1 over all test cases does not exceed 2172^{17}.

Output Format: For each test case print an integer xx. If there are multiple answers, print any.

Note: In the first test case, the original array is [3,2,1,0][3, 2, 1, 0].

In the second test case, the original array is [0,3,2,1][0, 3, 2, 1].

In the third test case, the original array is [2,1,0][2, 1, 0].

Sample Cases

Case 1

Input

3
0 3
3 2 1 0
0 3
4 7 6 5
0 2
1 2 3

Output

0
4
3

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback