Mirko has received an interesting homework assignment: to design his own little processor (Mirkoprocessor).
The processor has registers with indices from
to
,
and each register holds one unsigned
-bit integer in the usual binary format (the possible values range from
to
).
The processor is capable of executing the following instruction types:
Instruction type | Description | Example |
---|---|---|
1 K M |
Rotate the bits of register write the result back to register |
00000000000000000010001111111011 → ( 1010 ) →11111110110000000000000000001000 (in base 10: |
2 K L |
Compute bitwise output the result to the system bus. |
00000000000000000000001111000111 00000000000001111100000000000111 = 00000000000001111100001111000000 (in base 10: |
Mirko has already built a model of the processor, and only then realized that he'd forgotten to include an operation to read the contents of a register. Now, his only option is to execute a large number of type 1 and type 2 instructions and infer the register contents from the results. Having executed a sequence of commands, he has asked you to help him derive the initial register contents consistent with the obtained results.
If there are multiple possibilities for the initial register state combination, find the lexicographically
smallest one. (If two combinations have equal values in the first registers and different values in
register
, the lexicographically smaller combination is the one with the smaller value in register
.)
Input Specification
The first line of input contains two positive integers:
, the number of registers,
and
, the number of executed instructions.
The remaining input lines describe the instructions in the order that they were executed by
Mirkoprocessor, formatted as described in the table above, one per line. All instructions are legal (the
following conditions hold: ). Each instruction of type 2 is followed by
another line containing a positive integer between
and
, inclusive – the result of that operation
(the bitwise
value) in base 10.
In test data worth a total of points, the numbers
and
will be smaller than
.
Output Specification
The first and only line of output must contain the required register values, separated by spaces.
If there is no possible combination of initial values consistent with input, output only the number
-1
, to notify Mirko that his processor has a bug.
Sample Input 1
3 3
2 1 2
1
2 1 3
2
2 2 3
3
Sample Output 1
0 1 2
Sample Input 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
Sample Output 2
5 0 14 3
Sample Input 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
Sample Output 3
15 6 7 12 5
Comments