cswork / OAOpen practice workspace

AmazonOA #134

Discount Events

Estimated MediumJudge-ready

Topics (AI-labelled)Prefix & RangesSimulation

Operation 1 x v sets the price of item x directly to v (it may decrease); operation 2 v v raises every price below v to v. Execute them in the given order and output the final array.

Input

The first line contains n q, the second line contains n prices, followed by q lines of operations. Indices are 1-based, and the two values after type 2 are equal. This site sets 1≤n,q≤100000, and all prices and v are in 1..10⁹.

Output

Output the n final prices.

Example 1

Input:

2 2
1 9
2 5 5
1 2 2

Output:

5 2

Example 2

Input:

2 2
10 1
1 1 3
2 7 7

Output:

7 7

Example 3

Input:

1 3
5
1 1 2
1 1 9
2 6 6

Output:

9

Example notes

Example 1: after the floor the prices are 5, 9, then the second item is lowered to 2, so the final result is 5 2. Example 2: first 3, 1, then a uniform floor gives 7 7. Example 3: the final point assignment of 9 is not lowered by the floor 6, so the answer is 9.

Editorial

Loading solution…