#arc137d. [arc137_d]Prefix XORs

[arc137_d]Prefix XORs

Problem Statement

You are given an integer sequence of length NN: A=(A1,A2,cdots,AN)A=(A_1,A_2,\\cdots,A_N), and an integer MM.

For each k=1,2,cdots,Mk=1,2,\\cdots,M, find the value of ANA_N after doing the operation below kk times.

  • For every ii (1leqileqN1 \\leq i \\leq N), simultaneously, replace the value of AiA_i with A1oplusA2opluscdotsoplusAiA_1 \\oplus A_2 \\oplus \\cdots \\oplus A_i.

Here, oplus\\oplus denotes bitwise mathrmXOR\\mathrm{XOR}.

What is bitwise mathrmXOR\\mathrm{XOR}?

The bitwise mathrmXOR\\mathrm{XOR} of non-negative integers AA and BB, AoplusBA \\oplus B, is defined as follows:

  • When AoplusBA \\oplus B is written in base two, the digit in the 2k2^k's place (kgeq0k \\geq 0) is 11 if exactly one of AA and BB is 11, and 00 otherwise.

For example, we have 3oplus5=63 \\oplus 5 = 6 (in base two: 011oplus101=110011 \\oplus 101 = 110).
Generally, the bitwise mathrmXOR\\mathrm{XOR} of kk integers p1,p2,p3,dots,pkp_1, p_2, p_3, \\dots, p_k is defined as $(\\dots ((p_1 \\oplus p_2) \\oplus p_3) \\oplus \\dots \\oplus p_k)$. We can prove that this value does not depend on the order of p1,p2,p3,dotspkp_1, p_2, p_3, \\dots p_k.

Constraints

  • 1leqNleq1061 \\leq N \\leq 10^6
  • 1leqMleq1061 \\leq M \\leq 10^6
  • 0leqAi<2300 \\leq A_i < 2^{30}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM A1A_1 A2A_2 cdots\\cdots ANA_N

Output

Print the answers for respective values of kk, separated by spaces.


Sample Input 1

3 2
2 1 3

Sample Output 1

0 1

Each operation changes AA as follows.

  • Initially: A=(2,1,3)A=(2,1,3).
  • After the first operation: A=(2,3,0)A=(2,3,0).
  • After the second operation: A=(2,1,1)A=(2,1,1).

Sample Input 2

10 12
721939838 337089195 171851101 1069204754 348295925 77134863 839878205 89360649 838712948 918594427

Sample Output 2

716176219 480674244 678890528 642764255 259091950 663009497 942498522 584528336 364872846 145822575 392655861 844652404