Lands of Infinistan

n개의 직선과 하나의 비퇴화 이차곡선이 평면을 나누는 영역의 수를 구한다. 직선이 겹칠 수도 있다.

어려움8기하조합론아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

The country of Infinistan can be represented as an infinite plane. In the country there are nn 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 nn --- the number of straight walls (1n201 \le n \le 20).

The second line contains six integers q_0q\_0, q_1q\_1, q_2q\_2, q_3q\_3, q_4q\_4 and q_5q\_5 --- coefficients of the river that is a quadratic curve q_0x2+q_1xy+q_2y2+q_3x+q_4y+q_5=0q\_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 nn lines contains three integers a_ia\_i, b_ib\_i and c_ic\_i --- coefficients of the straight line a_ix+b_iy+c_i=0a\_i \cdot x + b\_i \cdot y + c\_i = 0.

All q_iq\_i, a_ia\_i, b_ib\_i and c_ic\_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 ii either a_i0a\_i \ne 0 or b_i0b\_i \ne 0.

출력

Print one integer --- the number of lands.