D. Limak and Shooting Points
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Bearland is a dangerous place. Limak can’t travel on foot. Instead, he has k magic teleportation stones. Each stone can be used at most once. The i-th stone allows to teleport to a point (axi, ayi). Limak can use stones in any order.
There are n monsters in Bearland. The i-th of them stands at (mxi, myi).
The given k + n points are pairwise distinct.
After each teleportation, Limak can shoot an arrow in some direction. An arrow will hit the first monster in the chosen direction. Then, both an arrow and a monster disappear. It’s dangerous to stay in one place for long, so Limak can shoot only one arrow from one place.