#P7476. 「C.E.L.U-02」苦涩

「C.E.L.U-02」苦涩

Description

In YQH's dream, he saw his past memories constantly surfacing in his mind. These memories brought him overwhelming bitterness. He wants to forcibly forget some of them to reduce his bitterness.

YQH's brain can be divided into nn sections. Each section is like a multiset that stores memories, and it is initially empty. He will perform mm operations of the following three types:

Operation 1: In every section in the interval lrl \sim r, a memory with bitterness value kk appears.

Operation 2: YQH starts cleaning the memories in sections lrl \sim r. If a section k[l,r]k \in [l,r] and the maximum bitterness value in section kk is equal to the maximum bitterness value among all sections lrl \sim r, then forget one such memory with the maximum bitterness value in that section. If there are multiple memories with the same maximum bitterness value in the same section, only one is forgotten. If a section has no memory, ignore it.

Operation 3: YQH wants to know the maximum bitterness value of memories among sections lrl \sim r. If it does not exist, output -1.

Input Format

The first line contains two numbers, n,mn, m.

The next mm lines: the first number represents the operation type opop. For operation 1, there are three numbers l,r,kl, r, k. For operation 2 or 3, there are two numbers l,rl, r.

Output Format

For each operation 3, output one line representing the answer.

5 4
1 1 3 2
1 2 4 3
2 3 3
3 1 3
3
6 6
1 1 6 2
1 3 3 2
1 3 4 3
2 3 4
3 3 3
3 4 4
2
2

Hint

Sample Explanation

Sample Explanation 1

Below is the state of YQH's brain after each operation: After the first operation: {2},{2},{2},,\{2\},\{2\},\{2\},\varnothing,\varnothing
After the second operation: {2},{2,3},{2,3},{3},\{2\},\{2,3\},\{2,3\},\{3\},\varnothing
After the third operation: {2},{2,3},{2},{3},\{2\},\{2,3\},\{2\},\{3\},\varnothing
The fourth operation queries the maximum value in interval 131 \sim 3, so the answer is 33.

Sample Explanation 2

Below is the state of YQH's brain after each operation: After the first operation: {2},{2},{2},{2},{2},{2}\{2\},\{2\},\{2\},\{2\},\{2\},\{2\}
After the second operation: {2},{2},{2,2},{2},{2},{2}\{2\},\{2\},\{2,2\},\{2\},\{2\},\{2\}
After the third operation: {2},{2},{2,2,3},{2,3},{2},{2}\{2\},\{2\},\{2,2,3\},\{2,3\},\{2\},\{2\}
After the fourth operation: {2},{2},{2,2},{2},{2},{2}\{2\},\{2\},\{2,2\},\{2\},\{2\},\{2\}
The fifth operation queries the maximum value of section 33, so the answer is 22.
The sixth operation queries the maximum value of section 44, so the answer is 22.

Constraints

Subtask n m Special Property
1(10pts)1(10pts) 103\leq10^3 103\le10^3 \diagdown
2(20pts)2(20pts) 5×104\leq5\times10^4 No operation 2.
3(10pts)3(10pts) In operation 2, l=rl=r.
4(20pts)4(20pts) \diagdown
5(20pts)5(20pts) 2×105\leq2\times10^5 In operation 2, l=rl=r.
6(20pts)6(20pts) \diagdown

For 100%100\% of the testdata, n,m2×105n, m \le 2 \times 10^5, k109k \le 10^9.

Translated by ChatGPT 5