Yellow Jackets - 2017 - Practice #3

Start

2017-09-13 23:10 CEST

Yellow Jackets - 2017 - Practice #3

End

2017-09-14 00:10 CEST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -11 days 16:16:54

Time elapsed

1:00:00

Time remaining

0:00:00

Problem C
Subway Planning

The government in a foreign country is looking into the possibility of establishing a subway system in its capital. Because of practical reasons, they would like each subway line to start at the central station and then go in a straight line in some angle as far as necessary. You have been hired to investigate whether such an approach is feasible. Given the coordinates of important places in the city as well as the maximum distance these places can be from a subway station (possibly the central station, which is already built), your job is to calculate the minimum number of subway lines needed. You may assume that any number of subway stations can be built along a subway line.

\includegraphics[width=0.75\textwidth ]{subway}
Figure 1: The figure above corresponds to the first data set in the example input.

Input

The first line in the input file contains an integer $N$, the number of data sets to follow. Each set starts with two integers, $n$ and $d$ ($1 \le n \le 500$, $0 \le d < 150$). $n$ is the number of important places in the city that must have a subway station nearby, and $d$ is the maximum distance allowed between an important place and a subway station. Then comes $n$ lines, each line containing two integers $x$ and $y$ ($-100 \le x, y \le 100$), the coordinates of an important place in the capital. The central station will always have coordinates $0,0$. All pairs of coordinates within a data set will be distinct (and none will be $0,0$).

Output

For each data set, output a single integer on a line by itself: the minimum number of subway lines needed to make sure all important places in the city are at a distance of at most $d$ from a subway station.

Sample Input 1 Sample Output 1
2
7 1
-1 -4
-3 1
-3 -1
2 3
2 4
2 -2
6 -2
4 0
0 4
-12 18
0 27
-34 51
4
2