At the end of a tasty meal, Capba just wants some tasty dessert. Today,
his cafeteria is serving a rectangular cake, with a coordinate system
carved on its delicious graham cracker crust base. The cake can be
thought of as a 2D grid of squares, with square
The cake also has
Capba likes icing… but then, he also doesn't like too much icing. He
considers
To decide on the best choice, he first wants to know how much icing is present in each potential piece of cake.
Input Specification
Line
Next
Next line:
Next
Output Specification
Note: The answers may overflow
Sample Input
6 5 3
1 3 4 5
1 1 6 1
2 2 3 3
5
2 1 2 2
5 2 6 5
2 4 2 4
3 1 4 2
2 1 4 4
Sample Output
2
0
1
3
13
Explanation for Sample Output
The cake has the following amounts of icing on it (in
111100
111100
122100
011000
111111
To answer the queries, just look at the diagram above and add up the numbers in each rectangle.
Comments