## CS345A1 - Red Blue Line Segments

no tags

There are n vertical line segments colored red and there are n horizontal line segments colored blue. We wish to find the number of red-blue pairs of intersecting segments.

These line segments are inside a unit square. Each blue segment is created by generating 3 random numbers (x1, x2, y) in the interval [0, 1]. These 3 numbers represent the segment joining (x1, y) and (x2, y). Red segments are generated similarly.

### Input

First line contains the number of segments n (n ≤ 100000)

next n lines define the blue segments. Each line contains 3 floating point numbers (in [0, 1]) x1 x2 y representing the segment joining (x1, y) and (x2, y).

next n lines define the red segments. Each line contains 3 floating point numbers (in [0, 1]) y1 y2 x representing the segment joining (x, y1) and (x, y2).

### Output

Print a single line containing the number of intersections.

Note: Touching line segments also count as intersecting. For example - blue segment joining (0.1, 0.2) and (0.3, 0.2) intersects with red segment joining (0.3, 0.4) and (0.3, 0.2).

### Example

```Input:
3
0.36295 0.557494 0.184032
0.0479258 0.214097 0.508344
0.234284 0.969098 0.739363
0.499323 0.739797 0.138495
0.829265 0.22551 0.290582
0.791082 0.069214 0.450979

Output:
4```