#P8318. 『JROI-4』淘气的猴子

『JROI-4』淘气的猴子

Background

As everyone knows, jockbutt is a cute girl.

Problem Description

jockbutt has a positive integer sequence of length nn, namely a1,a2,,ana_1,a_2,\cdots,a_n. 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 mm operations.

There are two types of operations:

  • 1 x y\texttt{1 x y} means adding the yy-th element to the xx-th element.
  • 2 x y\texttt{2 x y} means multiplying the xx-th element by the yy-th element.

In particular and obviously, when x=yx=y, the new value at position xx becomes double or squared compared to the original value at position xx.

The final sequence has the form b1,b2,,bnb_1,b_2,\cdots,b_n.

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, a1,a2,,ana_1,a_2,\cdots,a_n, otherwise she will cry...

Input Format

There are m+2m+2 lines in total.

The first line contains two integers n,mn,m.

The second line contains nn integers b1,b2,,bnb_1,b_2,\cdots,b_n, representing the sequence after all operations.

Lines 33 to m+2m+2 each contain three integers k,x,yk,x,y, representing the operation type and the xx and yy used in the operation.

Output Format

One line with nn integers a1,a2,,ana_1,a_2,\cdots,a_n, 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 1n,m101\leq n,m\leq 10
2 1n1001\leq n\leq 1001m501\leq m \leq 50
3 50 None
  • For 100%100\% of the data, 1n1031\leq n\le 10^3, 1m2001\leq m\le 200, and for any ii (1in)(1\leq i \leq n), 1ai,bi2601\leq a_i,b_i \leq 2^{60}.

Translated by ChatGPT 5