eolymp
bolt
Try our new interface for solving problems

XOR

Given a multiset S of non-negative integers, divide it into two multisets A and B in a way that minimizes |xor(A) - xor(B)|. Here xor(X) denotes the bitwise XOR of all elements of X.

Note that one of the multisets A and B can be empty, and XOR of an empty multiset is 0.

It is enough to output the minimum possible value of |xor(A) - xor(B)|.

Input

First line contains the number of test cases z (1z50). The descriptions of the test cases follow, two lines per test case.

The first line of every test case contains an integer n (1n105) - the size of the multiset.

The second line contains n integers xi (0xi1018) - elements of the multiset.

Output

For each test case output one integer: the smallest possible difference of XORs.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2
4
1 2 3 4
5
3 7 3 9 5
Output example #1
4
5
Source 2018 Petrozavodsk, Winter, Jagiellonian U, January 30, Problem A