#P9227. 异或积

异或积

Background

id: 4d7e\texttt{id: 4d7e}

Little H learned about the XOR operation in class.

For two non-negative integers x,yx, y, their XOR is defined as follows: treat them as binary numbers, and for each bit position compute the result bit by bit:

  • If the bits of xx and yy at this position are different, the result bit is 11.
  • If the bits of xx and yy at this position are the same, the result bit is 00.

The XOR of xx and yy is written as xxoryx \operatorname{xor} y or xyx \oplus y.

In C++, you can use x ^ y to get the XOR value of xx and yy.

Also, the XOR of multiple numbers is called the XOR sum.

Problem Description

Little H also learned that the XOR product of a sequence aa of length nn is a sequence bb of the same length, where bib_i equals the XOR sum of all elements in aa except aia_i, that is,

bi=j=1n[ji]ajb_i = \bigoplus \limits_{j = 1}^{n} [j\ne i] a_j

For example, the XOR product of the sequence {1,2,3,4}\{1, 2, 3, 4\} is {5,6,7,0}\{5, 6, 7, 0\}.

A XOR product transformation means replacing a sequence with its XOR product. Since the sequence length does not change after a transformation, the XOR product transformation can be applied multiple times in a row.

Now, Little H has a sequence aa of length nn. He wants you to help him compute the sequence obtained after applying kk XOR product transformations to aa.

Input Format

This problem contains multiple test cases within a single test point.

The first line contains an integer TT, the number of test cases.

For each test case:

The first line contains two integers n,kn, k.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n.

Output Format

For each test case:

Output one line with nn integers, representing the sequence obtained after applying kk XOR product transformations to sequence aa.

1
4 1
1 2 3 4
5 6 7 0
1
4 2
0 0 0 1
0 0 0 1
见附件中的 samples/xor3.in
见附件中的 samples/xor3.ans

Hint

Explanation for Sample 1

This sample is exactly the example given in the statement.

Explanation for Sample 2

After the 1st XOR product transformation: {0,0,0,1}{1,1,1,0}\{0,0,0,1\}\to\{1,1,1,0\};

After the 2nd XOR product transformation: {1,1,1,0}{0,0,0,1}\{1,1,1,0\}\to\{0,0,0,1\}.

Constraints

For 100%100\% of the testdata, 1T101 \le T \le 10, 2n1052 \le n \le 10^5, 1k10181 \le k \le 10^{18}, 0ai<2320 \le a_i < 2^{32}.

Test Point ID nn\leq kk \leq Special Property
131 \sim 3 100100
454 \sim 5 10001000
676 \sim 7 33 101810^{18}
8108 \sim 10 10510^5 33
111311 \sim 13 101810^{18} The XOR sum of all numbers in aa is 00
141514 \sim 15 nn is odd
161716 \sim 17 nn is even
182018 \sim 20

Notes

In C++, for the range 0x<2320 \le x < 2^{32}, you can:

  • Use unsigned int x to define it.
  • Use cin >> x or scanf("%u", &x) for input.
  • Use cout << x or printf("%u", x) for output.

Translated by ChatGPT 5