#P9635. 「yyOI R1」youyou 的异或
「yyOI R1」youyou 的异或
Background
youyou is very weak, but he really likes constructing strange sequences.
Problem Description
This problem uses Special Judge.
youyou likes sequences very much, so he wants you to construct a positive integer sequence of length .
youyou likes XOR, so he requires the constructed sequence to satisfy $a_1 \oplus a_2 \oplus a_3 \oplus \cdots \oplus a_{n-1} \oplus a_n = n$ (where denotes XOR).
youyou really hates identical numbers, so he requires that all numbers in the sequence are pairwise distinct.
But youyou does not want the numbers in this sequence to be too large, so he requires that the sum of all numbers in the sequence does not exceed , i.e., .
Now you need to construct a sequence that satisfies all of youyou's requirements. If there is no solution, output -1. If there are multiple answers, output any one of them.
You need to answer test cases.
Input Format
The first line contains a positive integer .
The next lines each contain an integer , meaning you need to construct a required sequence of length .
Output Format
Output lines in total.
If the -th line corresponds to constructing a sequence of length , then output exactly numbers on that line, representing your constructed sequence. Note that every number in the sequence must be a positive integer. If such a sequence cannot be constructed, output -1 on this line.
3
1
2
5
1
3 1
1 4 5 3 6
Hint
Sample Explanation
For , one feasible solution is .
For , one feasible solution is .
For , one feasible solution is , because , and , and all numbers in the sequence are also pairwise distinct.
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, , and .
Translated by ChatGPT 5