P4390 [BalkanOI 2007] Mokia

Description

The mobile phone company Mokia in Morvado has designed a new user localization system. Like other localization systems, it can quickly answer any question of the form “Where is user C?”, accurate to the millimeter. But its truly high-tech feature is that it can answer questions like “How many users are there in a given area?”. In this localization system, the world is considered a $w\times w$ square region, composed of $1\times 1$ cells. Each cell has a coordinate $(x, y)$, $1\leq x,y\leq w$. Coordinates are 1-indexed. For a $4\times 4$ square, we have $1\leq x\leq 4$, $1\leq y\leq 4$ (see the figure). ![](https://cdn.luogu.com.cn/upload/pic/17271.png) Please help Mokia write a program to compute how many users are in a rectangular region.

Input Format

There are three types of commands with the following meanings: | Command | Parameters | Meaning | |:-:|:-:|:-:| | $0$ | $w$ | Initialize an all-zero matrix. This command appears exactly once at the beginning. | | $1$ | $x\ y\ a$ | Add $a$ users to cell $(x, y)$. $a$ is a positive integer. | | $2$ | $x_1\ y_1\ x_2\ y_2$ | Query the number of users in the rectangle defined by $x_1\leq x\leq x_2$, $y_1\leq y\leq y_2$. | | $3$ | none | End the program. This command appears exactly once at the end. | The input consists of multiple lines. Each line contains several integers representing one command.

Output Format

For every command $2$, output one integer on a separate line: the number of users currently in the queried rectangle.

Explanation/Hint

Constraints For $100\%$ of the testdata, it is guaranteed that: - $1\leq w\leq 2\times 10 ^ 6$. - $1\leq x_1\leq x_2\leq w$, $1\leq y_1\leq y_2\leq w$, $1\leq x,y\leq w$, $0