Counting Neighbors#11861

Counting Neighbors

1 second
256 megabytes
Medium

You are given people standing at different positions on a 2D grid. Each person is located at a point with integer coordinates .

Two people are considered neighbors if the Manhattan distance between them is at most a given integer .

The Manhattan distance between two points (x_1, y_1) and (x_2, y_2) is defined as

|x_1 - x_2| + |y_1 - y_2|

Your task is to determine, for each person, how many other people are neighbors.

Input

The first line contains a single integer (1 \le t \le 10^4)—the number of test cases.

The first line of each test case contains two integers and (1 \le n \le 10^5, 1 \le d \le 3)—the number of people and the distance threshold.

Each of the next lines contains two integers x_i and y_i (-10^9 \le x_i, y_i \le 10^9)—the coordinates of the -th person.

It is guaranteed that the sum of over all test cases does not exceed 10^5.

It is guaranteed that all points are pairwise distinct.

Output

Print integers in a single line. The -th integer should represent the number of people (excluding the person themself) whose Manhattan distance from the -th person is less than or equal to .

Examples

Example 1

Loading
Loading

Note

Consider the first test case:

  1. Point . There are exactly points considered neighbors: , , .

  2. Point . There are exactly points considered neighbors: , , .

  3. Point . There are exactly points considered neighbors: , , .

  4. Point . There are exactly points considered neighbors: , , .

  5. Point . There are exactly points considered neighbors: , , , .

All of them have a distance of at most d = 2.

Scoring

  1. Subtask ( points): 1 \le n \le 10

  2. Subtask ( points): 1 \le n \le 1000

  3. Subtask ( points): d = 1

  4. Subtask ( points): -1000 \le x_i, y_i \le 1000

  5. Subtask ( points): No additional constraints.