Quaternary Computer

No attempts yetTime limit1sMemory limit512 MB

Problem

Gyeonggeun invented a new computer. Unlike other computers, it stores data in base 4 instead of base 2.

On this computer the results of p+qp + q and pqp \oplus q are given by the tables below. The row is pp and the column is qq.

p+qp + q

++0123
00123
11230
22301
33012

pqp \oplus q

\oplus0123
00123
11032
22301
33210

Gyeonggeun thought his invention was so innovative that he wanted to try it out at once, so he built the machine himself.

He put it together temporarily on a very small budget, so it stores only NN variables, and each variable holds a single integer from 0 to 3. For convenience Gyeonggeun numbered the variables from 0 to N1N - 1 and calls variable number ii by the name viv_i.

Gyeonggeun took his time and made the four basic commands he judged necessary.

  • addv x y z (0x,y,zN10 \le x, y, z \le N - 1, and xx, yy, zz are all integers): assigns the value of vy+vzv_y + v_z to vxv_x.
  • xorv x y z (0x,y,zN10 \le x, y, z \le N - 1, and xx, yy, zz are all integers): assigns the value of vyvzv_y \oplus v_z to vxv_x.
  • addc x y z (0x,yN10 \le x, y \le N - 1, 0z30 \le z \le 3, and xx, yy, zz are all integers): assigns the value of vy+zv_y + z to vxv_x.
  • xorc x y z (0x,yN10 \le x, y \le N - 1, 0z30 \le z \le 3, and xx, yy, zz are all integers): assigns the value of vyzv_y \oplus z to vxv_x.

Gyeonggeun wrote code that lists MM basic commands. Compiling the code produces a program. Before running any command, the program reads the value to store in each variable viv_i, executes the MM commands of the code one at a time in order, and then prints the value held by each variable viv_i once all commands are done. For convenience, write the input as a0,a1,,aN1a_0, a_1, \dots, a_{N-1} and the output as b0,b1,,bN1b_0, b_1, \dots, b_{N-1}.

Because of a mistake in Gyeonggeun's implementation, every variable viv_i has one value fif_i (0fi30 \le f_i \le 3) that cannot be stored in it at the start. So aifia_i \ne f_i must hold, and aia_i can be any of the three values among 0, 1, 2, 3 other than fif_i. There are therefore 3N3^N possible inputs.

To learn whether he wrote the program correctly, Gyeonggeun decides to go through every possible input. He bought a notebook of NN pages and numbered the pages from 0 to N1N - 1. He builds every possible input, feeds each one to the program once, takes the output b0,b1,,bN1b_0, b_1, \dots, b_{N-1} for that input, and writes the value of bib_i on page ii.

After every input has been gone through, let sis_i be the sum of the numbers written on page ii. Before starting the work, Gyeonggeun wants one minimal safeguard: the remainder of sis_i divided by 4, for every ii.

Input

The first line contains the number of variables NN (1N181 \le N \le 18) and the number of commands MM (0M4000 \le M \le 400).

The second line contains f0,f1,,fN1f_0, f_1, \dots, f_{N-1} (0fi30 \le f_i \le 3), separated by spaces. Here fif_i is the value that cannot be stored in variable viv_i before the commands run, and it is an integer.

Each of the next MM lines contains one command, in the order the commands run. Line jj (1jM1 \le j \le M) has one of the formats below. Every number given is an integer, and the numbers are separated by single spaces.

  • 0 x y z (0x,y,zN10 \le x, y, z \le N - 1): the jjth command to run is addv x y z.
  • 1 x y z (0x,y,zN10 \le x, y, z \le N - 1): the jjth command to run is xorv x y z.
  • 2 x y z (0x,yN10 \le x, y \le N - 1, 0z30 \le z \le 3): the jjth command to run is addc x y z.
  • 3 x y z (0x,yN10 \le x, y \le N - 1, 0z30 \le z \le 3): the jjth command to run is xorc x y z.

Output

Let tit_i be the remainder of sis_i divided by 4. Print t0,t1,,tN1t_0, t_1, \dots, t_{N-1} on the first line, separated by spaces.