Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to do some painting. As they were trying to create their first masterpiece, they made a draft on a piece of paper. The draft consists of n segments. Each segment was either horizontal or vertical. Now the friends want to simplify the draft by deleting some segments or parts of segments so that the final masterpiece meets three conditions:
As in other parts the draft is already beautiful, the friends decided to delete such parts of the draft that the sum of lengths of the remaining segments is as large as possible. Your task is to count this maximum sum of the lengths that remain after all the extra segments are removed.
The first line of the input contains integer n (1≤n≤2·105) − the number of segments on the draft. The next n lines contain four integers each: x1, y1, x2, y2 (-109≤x1≤x2≤109;-109≤y1≤y2≤109) − the two startpoint and the two endpoint coordinates of a segment. All segments are non-degenerative and either are strictly horizontal or strictly vertical.
No two horizontal segments share common points. No two vertical segments share common points.
Print a single integer − the maximum sum of lengths for the remaining segments.
2
0 0 0 1
1 0 1 1
1
4
0 0 1 0
0 0 0 1
1 -1 1 2
0 1 1 1
5
The shapes that you can get in the two given samples are:
In the first sample you need to delete any segment as the two segments together do not form a single connected shape.
In the second sample the initial segments form a cycle, there are four ways to break the cycle: delete the first, second or fourth segment altogether or delete the middle of the third segment. The last way is shown on the picture.