logo AlgoBeat OnlineJudge
登录 注册

#216990. [ICPC 2025 Shanghai R] Gemcrate

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Noir has gems. The -th gem has a positive integer written on it. Noir wants to divide these gems into several non-empty groups. Each gem belongs to exactly one group.

Suppose the -th group contains gems with label , then Noir treats the brightness of the -th group as , where is the bitwise-XOR operation. Denote the brightness of the -th group as .

For a grouping method of groups, Noir treats the value of this method as , where is the bitwise-AND operation.

Noir wants to find the maximum possible value over all grouping methods.

输入格式

The input contains multiple testcases. The first line of the input contains an integer (), the number of testcases.

For each testcase, the first line contains an integer (), the number of gems.

The second line contains integers (), the integers written on gems.

It’s guaranteed that the sum of over all testcases does not exceed .

输出格式

For each testcase, print an integer representing the maximum possible value over all grouping methods.

样例

样例输入 1

4
4
1 2 3 1
6
4 7 5 2 6 3
4
14 15 9 18
2
251508091405 13011908091815

样例输出 1

2
6
26
13121614001578

数据范围与提示

For the first testcase, a possible grouping method is with a value of . Another possible grouping method is , with a lower value . It can be proved that it’s not possible to achieve a value greater than .

For the second testcase, the best grouping method is with a value of .