P9785 [AOJ] Plane Division
普及
题目描述

Problem statement

The curve given by one implicit function $ Ax ^ 2 + Bxy + Cy ^ 2 + Dx + Ey + F = 0 $ and the straight line given by $ N $ implicit functions $ A_ix + B_iy + C_i = 0 $ is there. Find out how many regions the plane is divided by these curves and straight lines.

The following is a diagram of the Sample Input dataset.

<image> <image> <image>

Constraint

  • $1 \ leq N \ leq 20$
  • $-100 \ leq A, B, C, D, E, F \ leq 100$
  • $-100 \ leq A_i, B_i, C_i \ leq 100$
  • $A_i \ neq 0$ or $B_i \ neq 0$
  • The curve can be an ellipse (including a perfect circle), a parabola, or a hyperbola.
  • The same straight line may exist.

input

Input follows the following format. All given numbers are integers.

$ N $
$ A $ $ B $ $ C $ $ D $ $ E $ $ F $
$ A_1 $ $ B_1 $ $ C_1 $
$ ... $
$ A_N $ $ B_N $ $ C_N $

output

Output the number of areas on one line.

Examples

Input

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

Output

4

Input

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

Output

7

Input

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

Output

6

输入格式

见题面

输出格式

见题面

样例输入
2 1 0 -1 0 0 -1 3 0 6 -5 0 -10
样例输出
6