#P1450B. Balls of Steel

    ID: 2775 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>brute forcegeometrygreedy*1000

Balls of Steel

Description

You have nn distinct points (x1,y1),,(xn,yn)(x_1, y_1),\ldots,(x_n,y_n) on the plane and a non-negative integer parameter kk. Each point is a microscopic steel ball and kk is the attract power of a ball when it's charged. The attract power is the same for all balls.

In one operation, you can select a ball ii to charge it. Once charged, all balls with Manhattan distance at most kk from ball ii move to the position of ball ii. Many balls may have the same coordinate after an operation.

More formally, for all balls jj such that xixj+yiyjk|x_i - x_j| + |y_i - y_j| \le k, we assign xj:=xix_j:=x_i and yj:=yiy_j:=y_i.

An example of an operation. After charging the ball in the center, two other balls move to its position. On the right side, the red dot in the center is the common position of those balls.

Your task is to find the minimum number of operations to move all balls to the same position, or report that this is impossible.

The first line contains a single integer tt (1t1001 \le t \le 100) — the number of test cases.

The first line of each test case contains two integers nn, kk (2n1002 \le n \le 100, 0k1060 \le k \le 10^6) — the number of balls and the attract power of all balls, respectively.

The following nn lines describe the balls' coordinates. The ii-th of these lines contains two integers xix_i, yiy_i (0xi,yi1050 \le x_i, y_i \le 10^5) — the coordinates of the ii-th ball.

It is guaranteed that all points are distinct.

For each test case print a single integer — the minimum number of operations to move all balls to the same position, or 1-1 if it is impossible.

Input

The first line contains a single integer tt (1t1001 \le t \le 100) — the number of test cases.

The first line of each test case contains two integers nn, kk (2n1002 \le n \le 100, 0k1060 \le k \le 10^6) — the number of balls and the attract power of all balls, respectively.

The following nn lines describe the balls' coordinates. The ii-th of these lines contains two integers xix_i, yiy_i (0xi,yi1050 \le x_i, y_i \le 10^5) — the coordinates of the ii-th ball.

It is guaranteed that all points are distinct.

Output

For each test case print a single integer — the minimum number of operations to move all balls to the same position, or 1-1 if it is impossible.

Sample Input 1

3
3 2
0 0
3 3
1 1
3 3
6 7
8 8
6 9
4 1
0 0
0 1
0 2
0 3

Sample Output 1

-1
1
-1

Note

In the first test case, there are three balls at (0,0)(0, 0), (3,3)(3, 3), and (1,1)(1, 1) and the attract power is 22. It is possible to move two balls together with one operation, but not all three balls together with any number of operations.

In the second test case, there are three balls at (6,7)(6, 7), (8,8)(8, 8), and (6,9)(6, 9) and the attract power is 33. If we charge any ball, the other two will move to the same position, so we only require one operation.

In the third test case, there are four balls at (0,0)(0, 0), (0,1)(0, 1), (0,2)(0, 2), and (0,3)(0, 3), and the attract power is 11. We can show that it is impossible to move all balls to the same position with a sequence of operations.