#P10696. [SNCPC2024] 写都写了,交一发吧
[SNCPC2024] 写都写了,交一发吧
Problem Description
MCPlayer542 is solving a problem.
Since the problem is too hard, he cannot write the correct solution directly, so he wrote different pieces of code. The -th piece of code can get a score of .
Time is running out, so MCPlayer542 plans to submit code randomly. However, he then realizes that due to the special rules of this contest, he must submit code twice, and his total score will be the bitwise AND of the scores from the two submissions. Similar to the contest you are taking part in, the code submitted in the two submissions may be the same piece, or two different pieces.
Formally, if he submits the -th and the -th pieces of code in the two submissions, then the score is , where denotes the bitwise AND operation.
He wants to know the maximum score he can get.
Input Format
The input contains multiple test cases. The first line contains an integer (), indicating the number of test cases.
For each test case, the first line contains an integer (), indicating the number of pieces of code.
The next line contains integers (), separated by single spaces, with meanings as described above.
It is guaranteed that the sum of all does not exceed .
Output Format
For each test case, output one integer per line, which is the answer.
2
3
10 4 15
4
10 10 5 4
15
10
Hint
For the first test case, just submit the third piece of code twice.
For the second test case, submit the first two pieces of code.
Translated by ChatGPT 5