Submask Parity
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

Andrey gave Kirill a gift — an array of integers $$$a_1, a_2, \dots, a_n$$$, where $$$0 \le a_i < 2^{30}$$$.

Kirill is studying bitwise operations and is trying to understand how they can be used to determine whether a number is even or odd. During his study, he noticed that for some numbers, the result of the bitwise AND operation turns out to be special — for example, when applying this operation to a number with another number leaves it unchanged.

Andrey told Kirill that an integer $$$y$$$ is called a submask of a number $$$x$$$ if [ y  &  x = y, ] where "&" denotes the bitwise AND operation. In binary representation, this means that after padding both numbers with leading zeros to make them the same length, in all positions where $$$y$$$ has a 1, $$$x$$$ also has a 1. In other words, $$$y$$$ can be obtained from $$$x$$$ by replacing some of the 1-bits of $$$x$$$ with zeros.

For example, $$$1$$$ is a submask of $$$3$$$, since $$$1 = 2^0$$$, $$$3 = 2^0 + 2^1$$$. However, $$$2$$$ is not a submask of $$$12$$$, since $$$2 = 2^1$$$, while $$$12 = 2^3 + 2^2$$$.

Kirill became curious: does there exist an integer $$$x$$$ ($$$0 \le x < 2^{30}$$$) such that the number of elements in the array that are submasks of $$$x$$$ is odd? The number $$$x$$$ itself does not have to be present in the array.

If such a number exists, find any one of them. If no such number exists, report that there is no solution.

If the same number appears multiple times in the array, it is counted as many times as it occurs.

Input

The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 10^4$$$).

The descriptions of the test cases follow.

Each test case begins with a line containing a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements in the array.

The next line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i < 2^{30}$$$).

It is guaranteed that the sum of all $$$n$$$ over all test cases in one test does not exceed $$$10^5$$$.

Output

For each test case, print $$$-1$$$ if there does not exist an integer $$$x$$$ ($$$0 \le x < 2^{30}$$$) such that the array $$$a$$$ contains an odd number of its submasks.

Otherwise, print any such $$$x$$$.

Example

Input
3
5
1 2 3 4 5
4
1 1 1 1
3
1 1 2
Output
4
-1
3