Let $$$a$$$ be an array of length $$$n$$$. Define $$$\operatorname{mex}(a)$$$ as the smallest non-negative integer that does not appear in $$$a$$$. For example:
Define a $$$k$$$-transformation as follows: for each index $$$i$$$ ($$$1 \leq i \leq n$$$), independently choose to either keep $$$a_i$$$ unchanged or replace it with $$$k - a_i$$$. After all choices are made, we obtain a new array $$$a'$$$.
Define $$$k$$$-$$$\operatorname{mex}(a)$$$ as the maximum possible value of $$$\operatorname{mex}(a')$$$ among all arrays $$$a'$$$ that can be obtained from $$$a$$$ via a $$$k$$$-transformation.
You must answer $$$q$$$ queries. Each query provides a non-negative integer $$$k$$$; compute $$$k$$$-$$$\operatorname{mex}(a)$$$ for each query.
To reduce the output size, you are only required to output the bitwise XOR (exclusive-OR) of the answers over all $$$q$$$ queries.
The first line contains a single integer $$$T$$$ ($$$1 \leq T \leq 10^3$$$), denoting the number of test cases.
For each test case:
It is guaranteed that $$$\sum n \leq 5 \times 10^3$$$ and $$$\sum q \leq 5 \times 10^5$$$ across all test cases in one test file.
For each test case, output a single integer, denoting the bitwise XOR (exclusive-OR) of the answers to all queries in that test case.
230 1 3312590 0 1 1 2 3 3 4 5745678910
38
For the first test case:
Thus, the bitwise XOR of the answers to the three queries is $$$2\mathbin{\mathtt{\oplus}}2\mathbin{\mathtt{\oplus}}3=3$$$.
For the second test case, the answers to the queries $$$k=4,5,6,7,8,9,10$$$ are $$$6,6,7,8,6,7,6$$$, respectively, and their bitwise XOR is $$$8$$$.
| Название |
|---|


