问题 H: XOR Subsequence

内存限制:512 MB 时间限制:3 S
题面:传统 评测方式:文本比较 上传者:
提交:3 通过:3

题目描述

Alice used to have a sequence �1,⋯,��a1,,an, but she has forgotten about it now. Fortunately, she noticed that she had calculated the XOR sum for each non-empty subsequence of the sequence and obtained 2�−12n1 results, but their order was disrupted.

Now she hopes you can help restore the sequence. If there are multiple possible sequences, please tell her the sequence with the smallest lexicographical order, or report there is no correct sequence.

输入格式

The first line contains a single integer T (1≤�≤50001T5000), denoting the number of test cases.

For each test case, the first line contains an integer n (1≤�≤181n18).

The next line contains 2�−12n1 non-negative integers strictly less than 230230, denoting the results.

It is guaranteed that the sum of 2�2n over all test cases does not exceed 220220.

输出格式

For each test case, output one line. If there is no correct sequence, output −11; otherwise, output n integers denoting the answer.

输入样例 复制

3
3
1 2 3 4 5 6 7
3
1 0 1 0 1 0 1
3
1 2 3 4 5 6 6

输出样例 复制

1 2 4
0 0 1
-1