#ds303. 矩形面积并

矩形面积并

Rectangle Area Union

Problem Description

There are nn rectangles [Xi,1,Xi,2]×[Yi,1,Yi,2][X_{i,1}, X_{i,2}] \times [Y_{i,1}, Y_{i,2}] on the plane, i.e. rectangles whose lower-left corner is (Xi,1,Yi,1)(X_{i,1}, Y_{i,1}) and upper-right corner is (Xi,2,Yi,2)(X_{i,2}, Y_{i,2}). What is the area of their union?

Input Format

The first line contains an integer nn (1≤n≤2×1051\leq n\leq 2\times 10^5).

The next nn lines each contain four integers X1,X2,Y1,Y2X_1, X_2, Y_1, Y_2 ($1\leq X_1 \leq X_2 \leq 10^9,\ 1\leq Y_1 \leq Y_2 \leq 10^9$).

Note: empty rectangles may be present.

Output Format

Output one number, the answer.

Sample Input

2
1 4 2 3
2 3 1 4

Sample Output

5