Flame blast magician master qcjj
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Qcjj has been playing a role-playing game ''Flame blast magician master'' recently, in which the player will play as a hero who uses skills to attack monsters.

The world of the game can be regarded as a plane constituted by a two-dimensional coordinate of size . The lower left corner is the coordinate origin (0,0).

At the beginning of the game, there are N monsters. Among these monsters, the i-th monster is located in p_i(x_i,y_i) with the initial HP(health point) H_i.

There may be multiple monsters in the same position on this two-dimensional axis.
When the player hits the monster with a skill attack, the monster's HP will be reduced by 1

When a monster's HP , the monster will die immediately, and the player will receive the score V_i.

The killed monster will quit the game permanently.

Players can use the unique hero skill ''Flame Blast'' , generating a burning wall, perpendicular or parallel to the axis, attacking certain consecutive rows or columns.



As shown in the figure, for example, there are three monsters A,B,C in the two-dimensional coordinate axis.
Assume that the initial HP of those three monsters is all equal to 2 and the killing score is all equal to 1. Qcjj uses the ``Flame Blast'' skill twice.

Suppose the wall created by the first use of the skill is horizontal to the x axis, Attacking monsters A,B downwards from the top infinite distance. The A,B monster HP is reduced to 1. Since none of the monsters have been killed yet, the player's score at this moment is 0 points.Then the second skill creating the wall perpendicular to the x axis, attack monster A from the far left infinity to the right. The skill successfully hits A, causing the hp of A to be reduced to 0, and the player gets a total of 1 points for killing the monster A. At this time, the player's score is 1.

The entire process of the game can be abstracted as M events. Events are divided into three types. The first two events allow the player to use the `Flame Blast' skill to create a horizontal or vertical wall with the x axis as described earlier, which is used to attack monsters. The third event is the appearance of a monster at a specific position on the axis plane.

Now you need to write an instant game plugin that outputs the player's current score after each event.

In order to ensure the ''immediacy'' of your game plug-in, a part of the input data will be encrypted, forcing online decryption, the decryption method is described in ''input description''.

输入描述:

The first line of input is four positive integers N,M,P,Q (), Respectively represent the initial number of monsters N, a total of M events occurred in the entire game process, and the size of the game map is . The lower left corner of the game map is the coordinate origin (0,0).

Next input N lines of data.

each line of four non-negative integers x_i,y_i,H_i,V_i ().

Respectively represent the horizontal and vertical coordinates x_i, y_i of the monster, the initial HP H_i of the monster, and the reward score V_i after killing the monster.

Next M lines, each line begins with a parameter indicating the type of event Type_i.

When , it means that the player releases the wall parallel to the x coordinate axis, and attacks the monster downward from the uppermost infinite distance. At this time, it is necessary to continue to input two parameters l_i', r_i' (), where l_i',r_i' represents the encrypted attack range.

The decryption formula is:



where score represents the player's score before this attack.

Then all monsters are hit by the player's skills and suffer 1 points of damage. If a monster's HP is at this time, the monster will be killed, the player gets a kill score of V_i.

When , it means that the player releases the wall perpendicular to the x coordinate axis, and attacks the monster from the far left infinity to the right. At this time, it is necessary to continue to input two parameters l_i', r_i' (), where l_i',r_i' represents the encrypted attack range.

The decryption formula is:



where score represents the player's score before this attack.

Then all monsters are hit by the player's skills and suffer 1 points of damage. If a monster's HP at this time is , then the monster is killed, the player gets a kill score of V_i.

When , it means that a new monster has occurred. At this time, you need to continue to input four non-negative integers x_i,y_i,H_i,V_i ().

Respectively represent the horizontal and vertical coordinates of the monster x_i, y_i, the initial HP of the monster H_i, and the reward score V_i after killing the monster.

The player's initial score is 0.

输出描述:

Output M lines, each representing the player's game score score after each event.
示例1

输入

复制
3 4 15 8
5 4 2 1
5 5 2 1
4 5 2 1
1 5 8
2 1 4
3 4 5 1 1
2 4 1

输出

复制
0
1
1
3

说明

The player's initial score is 0.

The first event releases the wall that is parallel to the x axis, and attacks the monster downwards from the top infinite distance. Deal 1 damage.

The decrypted l and r are respectively 5 and 8 to attack the first two monsters, and the score at this time is score=0.

The second event releases the wall perpendicular to the x axis, and attacks the monster from the far left infinite distance to the right. Deal 1 damage. The decrypted l and r are respectively 1 and 4 to attack the first monster, and the score at this time is score=1.

The third event adds a new monster. Note that the added new monster can be located at the same coordinates as the existing monster. At this time, the score has not changed, and it is still score=1.

The fourth event releases a wall perpendicular to the x axis, dealing 1 point of damage, and attacks the monster from the far left infinite distance to the right. The decrypted l and r are respectively 2 and 5. Since the first monster has died, all the remaining monsters and the newly added monsters are attacked, and the score at this time is score=3.

Note that the coordinates of the monsters may overlap.
示例2

输入

复制
12 20 10 15
3 14 2 9
9 12 1 5
8 7 1 10
7 6 4 9
0 6 4 10
1 13 5 9
5 13 3 1
0 9 2 1
5 11 3 10
1 8 2 8
3 13 3 9
9 4 1 3
1 6 3
3 0 8 2 1
1 0 4
2 5 0
1 0 9
3 0 7 3 5
1 9 7
1 1 6
1 5 6
1 1 5
2 13 1
3 0 0 2 2
2 14 11
3 0 14 1 5
2 12 6
2 9 1
1 6 6
2 7 5
1 9 0
1 0 9

输出

复制
0
0
9
24
24
24
32
53
56
56
56
56
57
57
57
80
80
80
95
95