CSES - Aalto Competitive Programming 2024 - wk10 - Homework - Line Intersections
  • Time limit: 2.00 s
  • Memory limit: 512 MB

Given nn horizontal and vertical lines, your task is to calculate the number of their intersection points.

You can assume that the lines are all distinct.

Input

The first input line has an integer nn: the number of lines.

Then there are nn lines describing the lines. Each line has four integers: x1x_1, y1y_1, x2x_2 and y2y_2: a line that pass through the points (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2).

Output

Print the number of intersection points.

Constraints

  • 1n1051 \le n \le 10^5
  • 106x1,x2106-10^6 \le x_1, x_2 \le 10^6
  • 106y1,y2106-10^6 \le y_1, y_2 \le 10^6
  • (x1,y1)(x2,y2)(x_1,y_1) \neq (x_2,y_2)

Example

Input:

3
2 3 7 3
3 1 3 5
6 2 6 6

Output:

2