You are given an array A of size N. You have to perform Q queries on the array. Each of these queries belongs to the following types of queries:
However, it is not mandatory to perform the queries in order. Your task is to determine the lexicographically largest array that can be obtained by performing all the Q queries.
Note:
Input format
First line: Two space-separated integers N and Q
Next line: N space-separated integers denoting the array A
Next Q lines: The queries to be performed of the type L R X
Output format
Print N space-separated integers that denote the lexicographically largest array that can be obtained as mentioned in the problem statement.
Constraints
1≤N≤500
1≤Q≤105
type∈{1,2}
1≤L≤R≤N
−105≤X,Ai≤105
In this case, the order in which the queries are performed does not matter. Assuming the queries are performed in the same order as the input, the array after each query is as follows:
Initially, [1,2,3,4,5]
After query 1, [1,2,5,6,5]
After query 2, [3,3,5,6,5]
After query 3, [3,3,5,0,−1]
Observe that the final array would have been same even if the queries were performed in some other order.