War on Weather

Time limit1sMemory limit128 MB

Problem

After an unprovoked hurricane attack on the south shore, the Glorious Warrior (GW) has declared war on weather. The opening salvo is a coordinated pre-emptive strike on as many tropical depressions as possible — neutralizing them before they grow into storms and discouraging others from forming.

GW commands $k$ space-to-earth killer satellites placed at various points in space, and there are $m$ tropical depressions at various points on the Earth's surface. A satellite may attack any number of targets, as long as it has a clear line of sight to each one — that is, the straight segment from the satellite to the target does not pass through the Earth.

How many distinct targets can be hit by at least one satellite?

Input

The input consists of several test cases. Each case begins with a line containing two integers $k$ and $m$ ($0 < k, m \le 100$). The next $k$ lines each give a satellite's location as $x\ y\ z$; the following $m$ lines each give a target's location as $x\ y\ z$.

The Earth is a sphere centered at $(0, 0, 0)$ with a circumference of 40,000 km. Every target lies on the surface (within $10^{-9}$ km), and every satellite is at least 50 km above the surface. A line containing 0 0 follows the last test case.

Output

For each test case, output on its own line the total number of targets that can be hit. No target lies within $10^{-8}$ km of the boundary between having and not having a line of sight.