Baby Seokhwan

크기 M인 N개의 벡터에 범위 갱신으로 값을 채운 뒤, 벡터들을 사전순으로 정렬한 안정적인 최소 순열을 출력한다.

어려움8정렬구현아직 제출이 없습니다시간 제한5초메모리 제한768 MB

문제

Seokhwan is a cute 4-year-old baby. His teacher, Suryal, is teaching some knowledge suited for babies. Suryal brought a big whiteboard, which is essentially NN empty vectors (vectors filled with zeroes) of size MM, denoted by V_1,V_2,,V_NV\_1, V\_2, \cdots, V\_N.

Yesterday, Seokhwan learned how to write numbers. To test his ability, Suryal gave QQ queries to Seokhwan. For each query, Seokhwan is given four number S,E,P,XS, E, P, X. For all vectors V_S,V_S+1,,V_EV\_S, V\_{S+1}, \cdots, V\_E, Seokhwan should write XX to PP-th element of each vectors. It’s guaranteed that Seokhwan never overwrites (he never writes in a place where he already wrote something).

Today, Seokhwan learned how to sort a sequence in O(NlogN)O(N\log N) time complexity. To test his ability, Seokhwan should sort the vectors. Formally, Seokhwan should find a size-NN permutation P_1,P_2,,P_NP\_1, P\_2, \cdots, P\_N where V_P_iV_P_i+1V\_{P\_i} \leq V\_{P\_{i+1}} for all 1i<N1 \leq i < N. Suryal expects Seokhwan to do stable sort, thus if there are many such PP, then you should print the one which is lexicographically minimum.

Seokhwan did all those tasks in 8000ms, which Suryal don’t know how. You should help Suryal, and do what Seokhwan did. For two sequence L,RL, R of same size, RR is lexicographically greater than LL if and only if there exists some j\[1,M]j \in \[1, M] such that L_i=R_iL\_i = R\_i for all 1i<j1 \leq i < j and L_j<R_jL\_j < R\_j.

입력

The first line contains the number of vector NN, size of each vector MM, and number of queries QQ

In next QQ lines, four integer S,E,P,XS, E, P, X is given. This indicates that for all vectors V_S,V_S+1,,V_EV\_S, V\_{S+1}, \cdots, V\_E, Seokhwan should write XX to PP-th element of each vector.

출력

In ii-th line, print the ii-th element of permutation, which is the lexicographically minimum permutation which V_P_iV_P_i+1V\_{P\_i} \leq V\_{P\_{i+1}} holds.

제한

  • 1N,M,Q250 0001 \leq N, M, Q \leq 250\ 000 

For each query, the following constraints are satisfied:

  • 1SEN1 \leq S \leq E \leq N 
  • 1PM1 \leq P \leq M 
  • 1X250 0001 \leq X \leq 250\ 000