#P7759. [COCI 2012/2013 #3] PROCESOR

[COCI 2012/2013 #3] PROCESOR

Description

Mirko received an interesting assignment: to design his own small processor. This processor has nn registers numbered from 11 to nn. Each register stores an unsigned 3232-bit integer in binary form (possible values are in [0,2321][0,2^{32}-1]).

In addition, this processor is required to support the following two operations:

  • 1 k m: Move the last mm bits of the binary representation of the number in register kk to the very front as a whole, and then write the resulting new number back into register kk. For example:
$$\begin{aligned}&00000000000000000010001111111011\\\xrightarrow{m=10}&11111110110000000000000000001000\end{aligned}$$
  • 2 k l: Compute the XOR of the number in register kk and the number in register ll, and output the result to the system. For example:
$$\begin{aligned}&00000000000000000000001111000111\\ \underline{\text{XOR }} & \underline{00000000000001111100000000000111}\\ \text{= }&00000000000001111100001111000000\end{aligned}$$

Only after building the processor model did Mirko realize that he forgot to implement an operation to read the contents of a register. Therefore, the only thing he can do now is to execute operations 11 and 22 many times, and infer the register contents from the results. After executing a sequence of commands, he asks you to help him derive a set of initial register contents that is consistent with the obtained results.

If there are multiple possible sets of initial register states, you need to find the lexicographically smallest set (if two sets have equal values in the first k1k-1 registers but different values in register kk, then the lexicographically smaller set is the one with the smaller value in register kk).

Input Format

The input consists of multiple lines.

The first line contains two integers n,en,e, representing the total number of registers and the number of operations.
The next lines describe each operation. For an operation, first read a line with three integers op,k,l\textit{op},k,l, representing the operation type and its two parameters. If op=2op=2, then read one more line containing one integer, which is the result produced by the operation 22 on the previous line, and then proceed to the next operation on the following line. Otherwise, proceed directly to the next operation on the next line.

If you cannot understand the input format well, please refer to the sample to better understand this part.

Output Format

If there is no set of initial register contents consistent with the input, output a single line with the integer 1-1. Otherwise, output one line with nn integers, where the ii-th integer is the number initially stored in register ii.

3 3
2 1 2
1
2 1 3
2
2 2 3
3
0 1 2
4 6
2 4 2
3
2 4 1
6
1 3 1
2 3 1
2
1 2 2
2 2 3
7

5 0 14 3
5 6
2 4 2
10
2 5 3
2
2 2 3
1
2 1 4
3
1 3 1
2 3 4
2147483663
15 6 7 12 5

Hint

Constraints

For 40%40\% of the testdata, n,e1000n,e\leqslant 1000.
For all testdata, 2n1052\leqslant n\leqslant 10^5, 1e1051\leqslant e\leqslant 10^5. Also:

  • When op=1op=1, 1kn1\leqslant k\leqslant n, 0l320\leqslant l\leqslant 32.
  • When op=2op=2, 1k,ln1\leqslant k,l\leqslant n.

Source

This problem is from COCI 2012-2013 CONTEST 3 T6 PROCESOR. Using the original testdata configuration, the full score is 160160.

Translated and organized by Eason_AC.

Translated by ChatGPT 5