시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB32812210640.152%

문제

We define the beauty of an array as the value of its minimum excluded value (MEX$^{\dagger}$). A larger MEX corresponds to a more beautiful array.

You are given an array $A$ of length $N$. You want to enhance it in terms of its beauty. To achieve this, you can choose a non-negative integer $x$ and replace each element $A_i$ with $A_i\wedge x$ where $\wedge$ denotes the bitwise AND operator.

Find the optimal value of $x$ that maximizes the beauty of the array.

입력

The first line contains a single integer $T$ --- the number of test cases.

The first line of each test case contains a single integer $N$.

The second line of each test case contains $N$ space-separated integers $A_1,\ldots ,A_N$.

출력

For each test case, print a single line containing a single integer $x$ that maximizes the MEX of the array formed by taking the bitwise AND of each element of $A$ with $x$. If there are multiple solutions, you may print any.

제한

  • $1\le T\le 100\, 000$
  • $1\le N\le 100\, 000$
  • $0\le A_i<2^{30}\ (1\le i\le N)$
  • It is guaranteed that the sum of $N$ over all test cases does not exceed $100\, 000$.
  • All values in the input are integers.
  • $0\le x<2^{30}$
  • It can be shown that there always exists an optimal $x$ in the specified range.

예제 입력 1

1
6
13 11 40 10 33 19

예제 출력 1

23

노트

In the sample, we can choose $x=23$, so the new array will be \[[13\wedge 23,\, 11\wedge 23,\, 40\wedge 23,10\wedge 23,\, 33\wedge 23,\, 19\wedge 23] =[5,3,0,2,1,19]\] which has a MEX of $4$. Another possible answer is $x=19$.

${}^{\dagger}$ The MEX of an array is the smallest non-negative integer that does not belong to the array. For instance, the MEX of $[2,2,1]$ is $0$, the MEX of $[3,1,0,1]$ is $2$, and the MEX of $[0,3,1,2]$ is $4$.