eolymp
bolt
Try our new interface for solving problems
Problems

Combined rectangles

Combined rectangles

Combining rectangles is much easier when its sides are parallel to the coordinate axes. Find the total area covered by a given set of rectangles.

prb2926.gif

Input

The first line contains the number of rectangles n (2n3). Each of the next n lines contains coordinates of opposite corners of rectangle in format: x1 y1 x2 y2. The coordinates are integers in the range [-109, 109].

The rectangles can be degenerated.

Output

Print the total area covered by the given set of rectangles, rounded to the nearest integer.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2
0 0 10 10
20 5 5 20
Output example #1
300
Input example #2
2
0 0 10 10
20 15 15 20
Output example #2
125
Input example #3
2
0 0 10 10
3 5 5 3
Output example #3
100
Input example #4
3
0 0 4 4
1 1 5 2
1 1 2 5
Output example #4
18