Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

D. Ruminations on Ruminants

time limit per test

4 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputKevin Sun is ruminating on the origin of cows while standing at the origin of the Cartesian plane. He notices *n* lines on the plane, each representable by an equation of the form *ax* + *by* = *c*. He also observes that no two lines are parallel and that no three lines pass through the same point.

For each triple (*i*, *j*, *k*) such that 1 ≤ *i* < *j* < *k* ≤ *n*, Kevin considers the triangle formed by the three lines . He calls a triangle original if the circumcircle of that triangle passes through the origin. Since Kevin believes that the circles of bovine life are tied directly to such triangles, he wants to know the number of original triangles formed by unordered triples of distinct lines.

Recall that the circumcircle of a triangle is the circle which passes through all the vertices of that triangle.

Input

The first line of the input contains a single integer *n* (3 ≤ *n* ≤ 2000), the number of lines.

The next *n* lines describe lines . The *i*-th of these lines contains three space-separated integers *a*_{i}, *b*_{i}, *c*_{i} (|*a*_{i}|, |*b*_{i}|, |*c*_{i}| ≤ 10 000, *a*_{i}^{2} + *b*_{i}^{2} > 0), representing the equation *a*_{i}*x* + *b*_{i}*y* = *c*_{i} of line .

Output

Print a single integer, the number of triples (*i*, *j*, *k*) with *i* < *j* < *k* such that lines form an original triangle.

Examples

Input

4

1 0 0

0 1 0

1 1 -1

1 -1 2

Output

2

Input

3

0 1 1

1 1 2

1 -1 -2

Output

1

Note

Note that in the first sample, some of the lines pass through the origin.

In the second sample, there is exactly one triple of lines: *y* = 1, *x* + *y* = 2, *x* - *y* = - 2. The triangle they form has vertices (0, 2), (1, 1), ( - 1, 1). The circumcircle of this triangle has equation *x*^{2} + (*y* - 1)^{2} = 1. This indeed passes through (0, 0).

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/17/2019 22:39:48 (e1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|