eolymp
bolt
Try our new interface for solving problems
Problems

Union of rectangles 2

Union of rectangles 2

Union of rectangles is much easier when their sides are parallel to the coordinate axes. Find the union of the given set of rectangles.

Input

The first line contains the number of rectangles n (2n15). Each of the next n lines gives the coordinates of opposite corners of one rectangle in format x1 y1 x2 y2. All coordinates are integers and belongs to segment [-109, 109].

The rectangles can be irregular.

Output

Print the area of union of rectangles.

Time limit 1 second
Memory limit 122.49 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 10 10
13 5 5 13
12 12 15 15
Output example #4
147