Violet is an active comfort seeker and wishes to know the conditions required in order to achieve maximum comfort.
She has already determined the three conditions required in order to achieve a state of maximum comfiness, firstly a peaceful winter night, secondly a cup of hot chocolate and lastly a large window to observe the falling snow.
Violet's window is an
In order for Violet to maximize her enjoyment in the future, she has
R a b t
: The number of snowflakes there are located between row to , inclusive at time .C a b t
: The number of snowflakes there are located between column to , inclusive at time .V a b c d t
: The number of snowflakes there are located between row to , inclusive or column to , inclusive at time .
A snowflake that melts at time
Conversely, a snowflake that lands on the window at time
Note: There may be multiple snowflakes within the same grid at a given time but since all snowflakes are unique, they are to be counted separately.
Input
First line: Three integers,
Next
Next
For all queries:
The following additional constraints will apply.
- At least 20% of the marks will have test cases where
, , , , . - At least 40% of the marks will have test cases where
, , , , . - The remaining marks will have test cases where
, , , , .
Output
Output the answer to each query on its own line.
Sample Input
6 7 3
2 3 3 9
2 4 4 5
4 4 5 10
4 4 2 8
2 3 1 5
4 5 9 10
2 4 7 9
V 2 3 5 5 7
R 3 4 4
C 4 5 4
Sample Output
2
1
2
Comments
The problem states the constraint
0 <= a < n
, but it appears that there are no test cases wherea = 0
.