F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

XOR Subsequence

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 516    Accepted Submission(s): 223


Problem Description
Alice used to have a sequence $a_1,\cdots,a_n$, 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^n-1$ 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.
 

Input
The first line contains a single integer $T$ ($1\le T\le 5000$), denoting the number of test cases.

For each test case, the first line contains an integer $n$ ($1\le n\le 18$).

The next line contains $2^n-1$ non-negative integers strictly less than $2^{30}$, denoting the results.

It is guaranteed that the sum of $2^n$ over all test cases does not exceed $2^{20}$.
 

Output
For each test case, output one line. If there is no correct sequence, output $-1$; otherwise, output $n$ integers denoting the answer.
 

Sample Input
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
 

Sample Output
1 2 4 0 0 1 -1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 11:51:59, Gzip enabled