Interval Shuffle

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

Kanade has a sequence A_1...nA\_{1...n} and mm intervals \[L_i,R_i]\[L\_i, R\_i] of indices from 11 to nn, bounds included. He does mm operations in sequence, one for each interval. For the ii-th operation, Kanade can choose and perform one of the following two actions:

  1. Choose x\[L_i,R_i]x \in \[L\_i, R\_i] and update A_x:=A_x+1A\_x := A\_x + 1.
  2. Rearrange A_L_i...R_iA\_{L\_i...R\_i} in any order Kanade wants.

Now Kanade wants to know the maximum value of A_kA\_{k} after these operations. Find the answer for each k\[1,n]k \in \[1, n].

입력

The first line of input contains two integers nn and mm, the size of the sequence and the number of operations (1n,m21051 \leq n, m \leq 2 \cdot 10^5). The second line contains nn integers A_1...nA\_{1...n}, the initial sequence (0A_i21050 \leq A\_i \leq 2 \cdot 10^5).

Then follow mm lines. The ii-th of them contains two integers L_iL\_i and R_iR\_i describing the respective interval (1L_iR_in1 \leq L\_i \leq R\_i \leq n).

출력

Output nn integers, the ii-th of which is the maximum possible value of A_iA\_{i} after mm operations.