P9033 "KDOI-04" XOR Sum

Background

Kevin solved this problem at a glance. ![](https://cdn.luogu.com.cn/upload/image_hosting/lh1xvu75.png)

Description

Given a positive integer $n$, construct a sequence $a_1,a_2,\dots,a_n$ of length $n$ consisting of **non-negative integers**, such that: + For all $1\le i\le n$, we have $0\le a_i\le m$. + $a_1\oplus a_2\oplus\dots\oplus a_n=k$, where $\oplus$ denotes the [bitwise XOR](https://baike.baidu.com/item/%E5%BC%82%E6%88%96/10993677) operation. Or determine that no such sequence exists.

Input Format

**This problem contains multiple test cases.** The first line of the input contains a positive integer $T$, denoting the number of test cases. For each test case, the input contains one line with three non-negative integers $n,k,m$.

Output Format

For each test case, output one line with $-1$ to indicate that no such sequence exists. Otherwise, output $n$ **non-negative integers** separated by spaces, representing the sequence you construct. If there are multiple valid answers, you only need to output any one of them.

Explanation/Hint

**[Sample Explanation]** For the $1$st test case, there is one and only one sequence that satisfies the conditions. For the $2$nd test case, since $4\oplus 7=3$ and $4,7\le10$, this is a valid answer. Similarly, the sequence $(2,1)$ is also a valid answer. For the $4$th test case, it can be proven that there is no sequence that meets the requirements. **[Constraints]** Let $\sum n$ be the sum of all $n$ values within a single test point. For all testdata, it is guaranteed that $1\le T\le 1~000$, $1\le n\le 2\cdot10^5$, $0\le m,k\le 10^8$, and $\sum n\le 2\cdot10^5$. **[Subtasks]** **This problem uses bundled test cases.** + Subtask 1 (18 pts): $k\le m$. + Subtask 2 (82 pts): No additional constraints. Translated by ChatGPT 5