#P8468. [Aya Round 1 C] 文文的构造游戏
[Aya Round 1 C] 文文的构造游戏
Background
As everyone knows, Shameimaru Aya and Cirno are good friends. However, Aya is a powerful youkai and very smart, while Cirno is a fool. To improve Cirno’s IQ, Aya gave Cirno a simple problem.
Problem Description
For a sequence of length , define as the bitwise XOR sum of all elements, where denotes the bitwise XOR operation.
Given integers , determine whether it is possible to construct a sequence of length (you may choose ) such that:
- .
- .
- .
- .
Construct any valid solution, or report that no solution exists.
Input Format
This problem contains multiple test cases.
- The first line contains an integer , the number of test cases.
- The next lines each contain two integers , representing one query.
Output Format
- Output a total of lines.
- For each test case:
- If there is a solution, first output an integer , then output integers representing .
- If there is no solution, output a single integer on one line.
2
14 9
3 3
3 3 5 6
-1
Hint
Sample Explanation
- For test case , it is easy to see that and , which satisfies the requirements.
- For test case , the sequences , , and all do not satisfy the requirements, so there is no solution.
Constraints and Notes
For of the testdata, , , and .
Friendly reminder: you may need to use faster I/O.
Translated by ChatGPT 5