In ancient times, communication was not as swift as it is today. When a kingdom went to war, it could take months to muster all of its armed forces. Yet by lighting fire beacons placed at strategic locations, emergency signals could still be sent quickly.
When the first beacon is lit, every other beacon within sight of it is lit as well. Every beacon within sight of those is then lit, and so on, until all beacons are lit — assuming, of course, that all beacons are within sight of one another, either directly or indirectly. If they are not, the dire news must be carried by riders between some of the beacons.
Given the locations of all beacons in the kingdom, together with the location and size of every mountain peak, write a program that determines how many messages must be carried by riders so that all beacons can be lit when an enemy threatens the country.
To keep things simple, we model the country as follows: a beacon is a point in the xy-plane, and a mountain peak is a circle. Two beacons are within sight of each other if no mountain peak blocks the straight line segment between them.
The input is constructed so that the straight line between any pair of beacons never touches the circumference of a mountain peak, unless it passes through the interior of another mountain peak. Mountain peaks never overlap or touch, and no beacon lies on a mountain peak or on its circumference.
The first line contains two integers $n$ ($1 \le n \le 1000$) and $m$ ($0 \le m \le 1000$): the number of beacons and the number of mountain peaks, respectively. Each of the next $n$ lines gives the location of one beacon as a pair of integers $x$ and $y$ ($0 \le x, y \le 10000$). Each of the following $m$ lines describes one mountain peak as a pair of integers $x$ and $y$ ($0 \le x, y \le 10000$) giving the peak's location, followed by a radius $r$ ($1 \le r \le 5000$).
Output a single integer: the number of messages that must be carried by riders for all beacons to be lit.