Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

XORs

By kazi_nayeem · Limits 2s, 512 MB

You are given n integers as a1, a2, a3, a4, . . . . . . . ., an.

Firstly, you have to find the XORs of all of the pairs that can be formed from the given integers. That means, XOR (ai, aj) where 1 ≤ i, j ≤ n and i < j.

Finally, your ultimate goal is to find the cumulative XOR of previously found XORs of each pair.

Input

Input starts with an integer T (≤ 50), denoting the number of test cases.

The first line of each test case contains an integer n (2 ≤ n ≤ 105). The next line contains n space separated integers ai (1 in, 1 ai1000).

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

    Discussion

    Statistics


    50% Solution Ratio

    sakibalaminEarliest, Jan '18

    subhashis_cseFastest, 0.1s

    dip_BRURLightest, 131 kB

    saquib2508Shortest, 165B

    Submit

    Login to submit

    Related Contests

    NEUB Junior Inter University Programming Contest Ended at 2017-12-22 06:40:00 +0000 UTC
    Replay of NEUB Junior Inter University Programming Contest Ended at 2018-01-06 16:00:00 +0000 UTC