Combining Rectangles#4431

Combining Rectangles

1 second
64 megabytes
Very easy (≈850)

On a plane, you are given rectangles. Each rectangle has vertices at points with integer coordinates, and its sides are parallel to the coordinate axes.

Your task is to determine the total area covered by the union of these rectangles.

Input

The first line of the input contains the integer (0 \le N \le 1500). Each of the following lines contains four integers: x_1, y_1, x_2, y_2. These represent the coordinates of the bottom-left corner (x_1, y_1) and the top-right corner (x_2, y_2) of a rectangle (0 \le x_1 \le x_2 \le 10^9, 0 \le y_1 \le y_2 \le 10^9). Note that rectangles may degenerate into line segments or points.

Output

Output a single number representing the total area of the union of the rectangles.

Examples

Example 1

Loading
Loading