AND MEX
시간 제한2초메모리 제한1024 MB
모든 원소에 비트 AND를 적용할 값 x를 골라 결과 배열의 MEX가 최대가 되도록 한다.
문제
We define the beauty of an array as the value of its minimum excluded value (MEX). A larger MEX corresponds to a more beautiful array.
You are given an array of length . You want to enhance it in terms of its beauty. To achieve this, you can choose a non-negative integer and replace each element with where denotes the bitwise AND operator.
Find the optimal value of that maximizes the beauty of the array.
입력
The first line contains a single integer --- the number of test cases.
The first line of each test case contains a single integer .
The second line of each test case contains space-separated integers .
출력
For each test case, print a single line containing a single integer that maximizes the MEX of the array formed by taking the bitwise AND of each element of with . If there are multiple solutions, you may print any.
제한
- It is guaranteed that the sum of over all test cases does not exceed .
- All values in the input are integers.
- It can be shown that there always exists an optimal in the specified range.
힌트
In the sample, we can choose , 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 . Another possible answer is .
The MEX of an array is the smallest non-negative integer that does not belong to the array. For instance, the MEX of is , the MEX of is , and the MEX of is .