atarw is playing an excellently-crafted video game made by aurpine and Hypnova. This game takes place on a
by
rectangular grid, where
is the number of columns and
is the number of rows. There are
score multipliers each of which are applied to a specific range of columns or rows. These score multipliers stack, i.e. they are applied on the current score, not base score. This means that two
score multipliers are equivalent to a single
score multiplier. The base score changes depending on the level that atarw is playing on, however the multipliers remain the same.
See the input specification and sample for more details.
The objective of this game is to find a rectangular region where the total score (after multipliers) in the region is equal to the objective score. atarw wants to know how long it will take for him to find such a region. As an incompetent programmer, he has asked you to make a program that finds the number of valid rectangles given the base score (
) and the objective score (
). While he is playing the game, you will answer
such queries.
Constraints
Total absolute multiplier at any point is guaranteed to be less than
.

Variable | Subtask 1 [5%] | Subtask 2 [5%] | Subtask 3 [90%] |
 |  |  |  |
 |  |  |  |
 |  |  |  |
 |  |  |  |
 |  |  |  |
Note: You will have to use fast input methods.
Input Specification
The first line will contain the four space separated integers
,
,
,
.
The next
lines are of the following two forms denoting describing the multipliers:
c x y f
– an
score multiplier is applied to columns
.
r x y f
– an
score multiplier is applied to rows
.
The next
lines contain two space separated integers,
and
, the base and objective scores respectively.
Output Specification
lines each with a single integer corresponding to the number of rectangles that with the given base score adds up to the objective score.
Sample Input
Copy
3 3 3 1
c 2 3 2
c 3 3 4
r 2 3 3
3 72
Sample Output
Copy
2
Explanation for Sample Output
With a base score of
, the grid has the following scores.
Copy
________________________
| \\ C|| | | |
|R \\ || 1 | 2 | 3 |
|=====++=====+=====+=====|
| 1 || 3 | 6 | 24 |
|-----++-----+-----+-----|
| 2 || 9 | 18 | 72 |
|-----++-----+-----+-----|
| 3 || 9 | 18 | 72 |
|_____||_____|_____|_____|
There are only two rectangular regions that have a total score of
, the single squares
and
.
Comments
Do I get extra points for having the game installed?