시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 10 5 5 50.000%

문제

The country of Infinistan can be represented as an infinite plane. In the country there are $n$ straight walls and a river which has the form of a quadratic curve (an ellipse, a parabola or a hyperbola). The walls and the river divide the country into some lands of non-zero area. Your task is, given all the equations, to count the number of those lands.

입력

The first line contains a single integer $n$ --- the number of straight walls ($1 \le n \le 20$).

The second line contains six integers $q_0$, $q_1$, $q_2$, $q_3$, $q_4$ and $q_5$ --- coefficients of the river that is a quadratic curve $q_0\cdot x^2 + q_1 \cdot xy + q_2 \cdot y^2 + q_3 \cdot x + q_4 \cdot y + q_5 = 0$.

Each of the following $n$ lines contains three integers $a_i$, $b_i$ and $c_i$ --- coefficients of the straight line $a_i \cdot x + b_i \cdot y + c_i = 0$.

All $q_i$, $a_i$, $b_i$ and $c_i$ do not exceed 100 by absolute value. The straight lines may coincide. You may assume that the quadratic curve is not degenerate, and that for any $i$ either $a_i \ne 0$ or $b_i \ne 0$.

출력

Print one integer --- the number of lands.

예제 입력 1

1
1 0 1 0 0 -1
1 -1 0

예제 출력 1

4

예제 입력 2

2
1 0 0 0 -1 0
2 -1 -1
6 9 1

예제 출력 2

7

예제 입력 3

2
1 0 -1 0 0 -1
3 0 6
-5 0 -10

예제 출력 3

6