National Arena

Time limit: 1.5s Memory limit: 512MB Input: Output:

Task

National Arena is the largest stadium in Romania, hosting the most important matches.

For the next match of the national football team, the organizers have decided to arrange a choreography in Stand 1. The choreography consists of spectators wearing t-shirts with numbers that, when viewed from a distance, will form something relevant to that match.

Stand 1 has MM columns, and each column contains NN seats. The columns are numbered from 11 to MM from left to right, and the seats in a column are numbered from 11 to NN from bottom to top.

Thus, the organizing team has to manage QQ operations of three types on the stand:

  • 11 XX ii - The lowest unoccupied seat in column ii is taken by a spectator wearing a t-shirt with number XX;
  • 22 idxidx ii - The spectator sitting on seat with number idxidx in column ii leaves. Since people want a better view of the match, all spectators sitting in seats with higher numbers than idxidx in the same column move down one seat.
  • 33 stst drdr LL RR - what is the sum of the numbers written on the t-shirts of spectators sitting on seats with numbers in the range [st,dr][st, dr], in columns within the range [L,R][L, R]?

Your task is to help the organizers effectively manage these QQ operations.

Input data

The first line contains the numbers NN (1N1051 \leq N \leq 10^5), MM (1M51041 \leq M \leq 5 \cdot 10^4), and QQ (1QN1 \leq Q \leq N).

Each of the following QQ lines will describe an operation, as defined in the statement.

  • For operations of type 11: 0X1060 \leq X \leq 10^6 and 1iM1 \leq i \leq M.
  • For operations of type 22: 1idx1 \leq idx \leq the number of people then seated in column ii and 1iM1 \leq i \leq M.
  • For operations of type 33: 1stdrN1 \leq st \leq dr \leq N and 1LRM1 \leq L \leq R \leq M.

Output data

The number of type 33 operations will determine the number of lines in the output.

Each line will represent, in order, the answers to the type 33 operations and will contain a single number.

Example

stdin

4 3 11
1 3 1
1 7 1
1 5 3
3 1 2 1 3
2 1 1
1 4 2
1 5 2
1 6 2
3 1 3 1 3
2 2 2
3 1 2 2 3

stdout

15
27
15

Log in or sign up to be able to send submissions!