#P8318. 『JROI-4』淘气的猴子
『JROI-4』淘气的猴子
Background
As everyone knows, jockbutt is a cute girl.

Problem Description
jockbutt has a positive integer sequence of length , namely . She likes this sequence very much and usually takes good care of it.
But one day, when jockbutt was on a date with you, a naughty little monkey changed the sequence.
The monkey performed operations.
There are two types of operations:
- means adding the -th element to the -th element.
- means multiplying the -th element by the -th element.
In particular and obviously, when , the new value at position becomes double or squared compared to the original value at position .
The final sequence has the form .
When jockbutt came back, everyone on Luogu was watching the monkey. $\colorbox{white}{\color{white}{\text{Actually, maybe jockbutt is the “monkey” they are watching.}}}$
jockbutt is very angry and hopes you can tell her the initial sequence, that is, , otherwise she will cry...
Input Format
There are lines in total.
The first line contains two integers .
The second line contains integers , representing the sequence after all operations.
Lines to each contain three integers , representing the operation type and the and used in the operation.
Output Format
One line with integers , representing the initial sequence.
5 5
12 1 12 4 2
1 3 2
1 4 3
2 3 4
1 5 2
2 1 3
1 1 2 1 1
Hint
This problem uses bundled testdata.
| Subtask ID | Score | Special Constraints |
|---|---|---|
| 1 | 25 | |
| 2 | , | |
| 3 | 50 | None |
- For of the data, , , and for any , .
Translated by ChatGPT 5