Kevin hates implementation problems, but Paulo thinks they deserve a chance. He recently encountered a situation at home that required him to deal with a problem and he had a lot of fun solving it. This is the chance to show Kevin that implementation can be cool.
Paulo has a special programming language. The language only uses basic instructions and IFs. It follows the following grammar:
Program := Instruction
Program := Instruction
Program
Program := IF ci
Program
ELSE
Program
Instruction := ri += rj
Instruction := ri -= rj
Instruction := ri += V
Instruction := ri -= V
Instruction := ri SWAP rj
In this language:
ci
are global boolean variables initially set to false.ri
are global registers. They are not erased once the program runs, are initially set to 0, $$$(0\leq i \lt 3)$$$.V
are numerical values $$$(0\leq V \lt 10^9+7)$$$.The instructions do the following:
ri += rj
increments the value in register ri with the value in register rj.ri -= rj
decrements the value in register ri with the value in register rj.ri += V
increments the value in register ri with the value V.ri -= V
decrements the value in register ri with the value V.ri SWAP rj
swaps the values of registers ri and rj.In all instructions, all the xi are different from the xj, and sum and subtraction are defined modulo $$$10^9+7$$$.
The program runs as follows:
We run every instruction iteratively, applying the respective transformation. When we find an IF statement, we check the value of the associated boolean variable. If the value stored is true, then we run the program immediately below, otherwise we run the program below the ELSE.
Paulo wrote a program on his computer. Sometimes he looks at the values in the registers. Sometimes he runs the program several times. Sometimes he replaces a boolean variable with another boolean variable. Sometimes he notices a bug and changes an instruction to another instruction. Sometimes a boolean variable changes value (Paulo is careful so that no boolean variables change value while being used by the program).
Paulo has been doing this for a long time and keeps a list of the actions he took.
But tragedy happened; he lost the results of his calculations! He just knows the original code and the list of actions he took.
Help Paulo quickly regain the printed register values.
The first line has two integers, the number of lines of code $$$n$$$ $$$(1 \leq n \leq 5 \cdot 10^4)$$$ and the number of boolean variables $$$C$$$ $$$(1 \leq C \leq 5 \cdot 10^4)$$$.
Then $$$n$$$ lines follow, describing a valid program.
Then a line with a value $$$Q$$$ $$$(1 \leq Q \leq 5 \cdot 10^4)$$$, the number of actions Paulo took. The following $$$Q$$$ lines contain the actions Paulo took in order, and they are one of the following categories:
0
Print the values on the three registers.1 x
Run the current program $$$x$$$ $$$(1 \leq x \leq 10^9)$$$ times.2 l ci
Change the IF in line $$$l$$$ $$$(1 \leq l \leq n)$$$ (it's guaranteed that there's an IF in line $$$l$$$) to use boolean variable ci instead $$$(0 \leq i \lt C)$$$.3 l Instruction
Change the instruction in line $$$l$$$ $$$(1 \leq l \leq n)$$$ (it's guaranteed that there's an instruction in line $$$l$$$) to use the new instruction instead. Instruction is a valid instruction.4 ci
Change the boolean value of boolean variable ci. It's guaranteed ci is not being used by the code at the moment.Print a line with the values inside the registers for every time there's a query of type 0. You should print the values in the registers in order, separated by a space. This means
r0 r1 r2
5 2IF c0r1 += r0r0 SWAP r1ELSEr0 += 12404 c11 102 1 c11 101 101 101 101 101 103 2 r0 SWAP r13 3 r1 -= r03 5 r0 -= 11 62 1 c01 10
0 0 0 1 0 0 1 1 0 2 1 0 3 2 0 5 3 0 8 5 0 13 8 0 0 0 0
2 1r1 += 1r2 -= 121 10000000000
0 1000000000 7
| Name |
|---|


