Kanade has a sequence A_1...n and m intervals \[L_i,R_i] of indices from 1 to n, bounds included. He does m operations in sequence, one for each interval. For the i-th operation, Kanade can choose and perform one of the following two actions:
Now Kanade wants to know the maximum value of A_k after these operations. Find the answer for each k∈\[1,n].
The first line of input contains two integers n and m, the size of the sequence and the number of operations (1≤n,m≤2⋅105). The second line contains n integers A_1...n, the initial sequence (0≤A_i≤2⋅105).
Then follow m lines. The i-th of them contains two integers L_i and R_i describing the respective interval (1≤L_i≤R_i≤n).
Output n integers, the i-th of which is the maximum possible value of A_i after m operations.