As you try to add some graphics for a splash screen, you notice that RtP does not execute your program sometimes! As you slowly pull your hair out on trying to figure out the issue, a classmate tells you that the reason why your program isn't running is that some pixels have too many draw commands on that pixel!
The console is by pixels, with columns and rows, where is the top-left corner and is the bottom-right corner. You have drawn rectangles, each with the top-left corner at row and column , as well as width and height . Your friend has looked at your console and given you queries. For each query, similarly to the input of the rectangles drawn, you are given the top-left corner and the width and height of the rectangle. In this rectangle, you want to find the number of pixels that have more than rectangles drawn over that pixel in the rectangular query.
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
No further constraints.
Input Specification
The first line will contain space-separated integers .
The next lines will contain space-separated integers .
The next lines will contain space-separated integers .
Output Specification
Output lines, the number of pixels that have at least rectangles drawn over it.
Sample Input
5 5 5 1 3
1 1 4 4
2 2 3 3
2 2 1 1
4 4 1 1
1 1 1 1
1 1 4 4
Sample Output
8
Sample Explanation
The points (2,2), (2,3), (3,2), (3,3), (4,4), (4,5), (5,4), and (5,5) have at least 3 overlapping rectangles.
Here is a diagram of the squares:
Comments