Lester intends to major in Physics with a specialization in Relativistic Astrology. Tonight, he observes the night sky to refine his calculations for when the heat death of the universe will occur. However, Lester got distracted. He saw that some stars in the night sky form isosceles triangles. Now, he wants to count the number of isosceles triangles formed by stars in the night sky.

The night sky can be modelled as a Cartesian coordinate plane. Each of the $N$ stars $S_i$ is located at $(X_i, Y_i)$ where $X_i$ and $Y_i$ are integers. It is guaranteed that no two stars are located at the same coordinate. Two triangles are different if there is a star which is part of the first triangle but not the second triangle. For simplicity, we will only count isosceles triangles which have a base parallel to the x-axis. An isosceles triangle $\Delta ABC$ with $AC = BC$ has $AB$ as its base, it is only counted if $AB$ is parallel to the x-axis.

The (Euclidean) distance between two points $A = (X_i, Y_i)$ and $B = (X_j, Y_j)$ is given by:

$$AB = \sqrt{(X_i - X_j)^2 + (Y_i - Y_j)^2}$$

For example, three stars at $A = (1, 1), B = (3, 1), C = (2, 69)$ forms an isosceles triangle we will count because $AC = BC$ and the base $AB$ is parallel to the x-axis.

Figure. Quality illustration by Sunny.

Note: we do not count degenerate triangles (triangles with zero area).

Input

The first line of input consists of an integer $N$.
Each of the next $N$ lines of input contains a coordinate $(X_i, Y_i)$, the location of a star.

Output

Output the number of isosceles triangles with base parallel to the x-axis.

Constraints

For all cases: $1 \le N \le 5000, -10^{18} \le X_i, Y_i \le 10^{18}$
Subtask 1 (10%): $N \le 3, -10^{9} \le X_i, Y_i \le 10^{9}$
Subtask 2 (30%): $N \le 700, -10^{9} \le X_i, Y_i \le 10^{9}$
Subtask 3 (30%): No 3 stars have the same y-coordinate
Subtask 4 (30%): No additional constraints

Sample Test Cases

Input Output
4
1 1
2 1
3 1
2 69
1
Note that (1, 1), (2, 1) and (3, 1) forms a degenerate isoceles triangle which should not be included in the answer.
5
0 0
1 1
-1 1
1 -1
-1 -1
2
Note that the triangle (0, 0), (1, 1) and (1, -1) has its base parallel to the y-axis which should not be included in the answer.
3
-10 -1
-9 -2
-8 -1
1
Click to copy.

Scoring: Per Subtask
Authored by s16f22 and s17r28
Appeared in 2023 Wah Yan Interschool Olympiad in Informatics 🤯🥷⚡🧠🏆