Crazy Fences

No attempts yetTime limit1sMemory limit128 MB

Problem

Farmer John is redesigning his farm by rearranging all $N$ fences between his pastures ($1 \le N \le 1000$). Each fence is a straight line segment in the 2D plane. Two fences may meet only at their endpoints, and every fence meets exactly two other fences — one at each of its two endpoints. As a result, the fences form one or more disjoint closed polygons.

Farmer John has $C$ cows ($1 \le C \le 1000$). Each cow stands at a point that lies on no fence, and no two cows stand at the same point. Two cows belong to the same community if one of them can walk to the other without ever crossing a fence.

Report the size of the largest community.

Input

  • Line 1: two space-separated integers $N$ and $C$.
  • Lines $2 \dots N+1$: four integers $x_1\ y_1\ x_2\ y_2$, describing a fence from $(x_1, y_1)$ to $(x_2, y_2)$.
  • Lines $N+2 \dots N+C+1$: two integers $x\ y$, the location of a cow.

All coordinates are integers from 0 to 1,000,000.

Output

  • A single integer: the number of cows in the largest community.

Hint

Because the fences form closed loops, two cows share a community exactly when the same set of loops encloses both of them. In the sample, the fences form a square that contains two triangles; two of the four cows fall inside the same set of loops and share a community, while the remaining two are each alone.