Marek loves mathematics, especially geometry. One idle afternoon he grabbed his favourite ruler and drew a handful of horizontal and vertical line segments. When he looked at the paper afterwards he noticed rectangles outlined by the segments, but every time he recounted them he got a different total, so he needs your help.
You are given N axis-aligned segments; each one is either horizontal (parallel to the x-axis) or vertical (parallel to the y-axis). Your task is to count how many axis-aligned rectangles are outlined by the drawn segments.
A rectangle has its left and right sides on the vertical lines x=xL<xR and its bottom and top sides on the horizontal lines y=yB<yT. It is counted only when all four sides are completely drawn:
A single side may be covered by the union of several collinear segments that overlap or merely touch, and segments are allowed to overlap or coincide.
The first line contains the number of segments N (4≤N≤800).
Each of the next N lines contains four integers x1, y1, x2, y2 (−109≤x1,y1,x2,y2≤109), where (x1,y1) is one endpoint of a segment and (x2,y2) is the other. Every segment is parallel to the x-axis or to the y-axis.
Print a single line containing the number of rectangles.
In the first test case the rectangles split by size into four 1×1, three 2×1, two 3×1, and one 4×1, giving 4+3+2+1=10 in total. Note that the bottom side of the widest rectangle is covered by two horizontal segments that touch, which still counts as fully drawn.