Limits 2s, 512 MB

You are given nn integers as a1a_1, a2a_2, a3a_3, a4a_4, …, ana_n.

First of all, you have to find the XORs of all of the pairs that can be formed from the given integers. That means, XOR(ai,aj)XOR(a_i, a_j) where 1i,jn1 \le i, j \le n and i<ji < j. Finally, your ultimate goal is to find the cumulative XOR of previously found XORs of each pair.

Input

Input starts with an integer TT (0<T500 < T \le 50), denoting the number of test cases.

The first line of each test case contains an integer nn (2n1052 \le n \le 10^5). The next line contains nn space separated integers aia_i (1in1 \le i \le n, 1ai10001 \le a_i \le 1000).

Output

For each case, print a single line containing a single integer which denotes the final result.

Sample

InputOutput
2
2
3 4
5
1 2 2 4 5
7
0

Submit

Login to submit.

Statistics

54% Solution Ratio
sakibalaminEarliest, Jan '18
steinumFastest, 0.0s
steinumLightest, 5.5 kB
saquib2508Shortest, 165B
Toph uses cookies. By continuing you agree to our Cookie Policy.