Due to the high cost of flowers in Alberta, Yraglac decided
it would be a good idea to plant his own flower garden instead
of buying flowers for his girlfriend. We can model his flower
garden on a two-dimensional grid, where the position of each
flower is given by an coordinate. Today, Yraglac
decided it would be a good idea to water his flowers one by
one, starting at the origin and walking to each flower. He
will take the shortest path at each step. However, it turns out
that Yraglac has an important meeting today and has a limited
amount of time available to water the flowers. Thus, he has
ranked all of the flowers in his garden from most to least
important and will water them in that order. For religious
reasons, the number of flowers watered by Yraglac must be a
prime number, or zero. Help Yraglac find the maximum number of
flowers he can water.
Input
The first line contains a single integer giving the number of test
cases. Each test case starts with a line containing an integer
(), the number
of flowers in the garden, and an integer (), the maximum total distance that can
be travelled by Yraglac. The next lines contain two integers
and (), the
coordinates of the th
flower. The flowers are ordered from most to least important.
Every flower has a different position, and there will not be a
flower at the origin .
Output
For each test case, output a single line containing the
maximum number of flowers that Yraglac can water.
Sample Input 1 |
Sample Output 1 |
3
2 1
0 1
1 0
2 2
0 1
1 0
2 3
0 1
1 0
|
0
0
2
|