CF1805A.We Need the Zero

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

We Need the Zero

There is an array aa consisting of non-negative integers. You can choose an integer xx and denote bi=aixb_i=a_i \oplus x for all 1in1 \le i \le n, where \oplus denotes the bitwise XOR operation. Is it possible to choose such a number xx that the value of the expression b1b2bnb_1 \oplus b_2 \oplus \ldots \oplus b_n equals 00?

It can be shown that if a valid number xx exists, then there also exists xx such that (0x<280 \le x \lt 2^8).

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t10001 \le t \le 1000). The description of the test cases follows.

The first line of the test case contains one integer nn (1n1031 \le n \le 10^3) — the length of the array aa.

The second line of the test case contains nn integers — array aa (0ai<280 \le a_i \lt 2^8).

It is guaranteed that the sum of nn over all test cases does not exceed 10310^3.

Output

For each set test case, print the integer xx (0x<280 \le x \lt 2^8) if it exists, or 1-1 otherwise.

Note

In the first test case, after applying the operation with the number 66 the array bb becomes [7,4,3][7, 4, 3], 743=07 \oplus 4 \oplus 3 = 0.

There are other answers in the third test case, such as the number 00.

Samples

5
3
1 2 5
3
1 2 3
4
0 1 2 3
4
1 2 2 3
1
1
6
0
3
-1
1

在线编程 IDE

建议全屏模式获得最佳体验