#P8512. [Ynoi Easy Round 2021] TEST_152

[Ynoi Easy Round 2021] TEST_152

Problem Description

Zhuanzhuan has an operation sequence of length nn, (li,ri,vi)(l_i, r_i, v_i).

Now there are qq queries (L,R)(L, R).

For each query, you initially have a sequence cc of length mm, with all initial values equal to 00.

Now we execute, in order, the operations corresponding to items L,L+1,L+2,,RL, L+1, L+2, \cdots, R of the operation sequence.

Each operation sets clic_{l_i} through cric_{r_i} to viv_i.

For each query, output the sum of all numbers in the entire sequence cc after all operations finish.

Queries are independent of each other.

Input Format

The first line contains three positive integers n,m,qn, m, q.

Lines 22 to n+1n+1 each contain three positive integers. Line i+1i+1 gives li,ri,vil_i, r_i, v_i.

The next qq lines each contain two positive integers, describing one query L,RL, R.

Output Format

Output qq lines, each containing one positive integer, the answer to the query.

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

8
14
4

10 10 10
1 5 20
5 7 7
3 6 8
1 6 20
1 7 14
5 6 5
9 9 18
5 10 5
1 9 6
1 5 19
1 10
5 5
7 10
4 8
1 9
1 6
6 7
7 10
2 6
1 4

124
98
124
86
59
80
28
124
80
127

Hint

Idea: Ynoi, Solution: Ynoi, Code: Ynoi, Data: Ynoi

For 100%100\% of the testdata, it holds that:

1n,m,q5×1051 \le n, m, q \le 5 \times 10^5.

1lirim1 \le l_i \le r_i \le m.

0vi2×1090 \le v_i \le 2 \times 10^9.

1LRn1 \le L \le R \le n.

Translated by ChatGPT 5