JOI and IOI are best friends. One day, JOI and IOI went to stargaze at an observatory on top of a mountain.
From the observatory, N stars are visible. Each star is numbered from 1 to N, and is either red, blue, or yellow in color.
The stars visible from the observatory can be represented as points on a coordinate plane. In this coordinate plane, the point corresponding to star \(i\) \((1 \leq i \leq N)\) is \(P_i(X_i, Y_i)\).
No two of the points \(P_1, P_2, ... P_N\) are located at the same position, and no three points are collinear.
JOI and IOI decided they wanted to create a constellation, which they would name JOIOI. First, they thought of using a triangle to connect three stars of different colours: red, blue, and yellow. Such a triangle is called a good triangle.
The two of them decided that each pair of good triangles is a candidate for the JOIOI constellation, so long as they satisfy the following condition:
The first line of input consists of a single integer \(N\), the number of stars visible from the observatory.
\(N\) lines of input follow. The \(i^{th}\) of these lines contains 3 integers \(X_i\), \(Y_i\), and \(C_i\), denoting that the \(i^{th}\) star is located at \(P_i(X_i, Y_i)\), and has colour \(C_i\). The star is red if \(C_i\) is 0, blue if 1, and yellow if 2.
Output a single integer on a single line, the total number of candidates for the JOIOI constellation.
Subtask #  Score  Constraints 

1  15  \(n \leq 30\) 
2  40  \(n \leq 300\) 
3  45  No additional constraints 
Sample Input 1  Sample Output 1 
7
0 0 0

4

In this input example, the stars are arranged as shown in the figure below. In this figure, the red stars are represented by circles, the blue stars by diamonds, and the yellow stars by triangles.
The four constellations satisfying the required conditions are:
Sample Input 2  Sample Output 2 
8
16 0 0

12

Sample Input 3  Sample Output 3 
21

7748

Subtask  Score 

1  15 
2  40 
3  45 
4  0 