Given n rectangle Ri, i = 1, 2, ..., n in the Euclidean plane. The lower left point and upper right point of Ri is (0, 0) and (ui, ri) repectively.
Find the number of pairs (i, j) such that Ri can be contained in Rj after rotating 90o or 0o. Formally speaking, find the number of pairs (i, j) that satisfy at least one of the following conditions:
For example, the following two rectangles satisfy the condition, since the blue rectangle can be contained in the red rectangle by rotating 90o (see picture on right hand side).
The first line contains an integer n. For the next n line, each line contains two integers ui, ri, i = 1, 2, ..., n.
Output one integer: the number of pairs satisfying the condition above.