#D11033. Plane Division

    ID: 9171 Type: Default 1000ms 134MiB

Plane Division

Plane Division

Problem statement

The curve given by one implicit function Ax2+Bxy+Cy2+Dx+Ey+F=0 Ax ^ 2 + Bxy + Cy ^ 2 + Dx + Ey + F = 0 and the straight line given by N N implicit functions Aix+Biy+Ci=0 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.

Constraint

  • 1 leqN leq20 1 \ leq N \ leq 20
  • 100 leqA,B,C,D,E,F leq100 -100 \ leq A, B, C, D, E, F \ leq 100
  • 100 leqAi,Bi,Ci leq100 -100 \ leq A_i, B_i, C_i \ leq 100
  • Ai neq0 A_i \ neq 0 or Bi neq0 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 N A A B B C C D D E E F F A1 A_1 B1 B_1 C1 C_1 ... ... AN A_N BN B_N CN 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

inputFormat

Input dataset.

Constraint

  • 1 leqN leq20 1 \ leq N \ leq 20
  • 100 leqA,B,C,D,E,F leq100 -100 \ leq A, B, C, D, E, F \ leq 100
  • 100 leqAi,Bi,Ci leq100 -100 \ leq A_i, B_i, C_i \ leq 100
  • Ai neq0 A_i \ neq 0 or Bi neq0 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 N A A B B C C D D E E F F A1 A_1 B1 B_1 C1 C_1 ... ... AN A_N BN B_N CN C_N

outputFormat

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