This page is still under construction.

Parts of this page are still being built. What you see may change.

Space

Time limit1sMemory limit128 MB

Summary
Count, for each test case, the pairs of up to 100000 points whose Euclidean distance is strictly less than d.
Level

Medium5 of 10

Topics
Hash map, Geometry
Solved
No attempts yet

Problem

Teams at a programming contest cannot sit close to one another, because a team could copy the solution of the team next to it. You are given the position of every team and the minimum Euclidean distance dd required between two teams. Count the pairs of teams that sit too close to each other.

Two teams sit too close when the Euclidean distance between them is smaller than dd. A pair at distance exactly dd does not count.

Input

The first line contains one integer tt (1≤t≤1001 \le t \le 100), the number of test cases. Each test case is given as follows.

  • One line with two integers nn (1≤n≤1000001 \le n \le 100000) and dd (1≤d≤501 \le d \le 50), the number of teams and the minimum distance between two teams.
  • nn lines with two integers xix_i (0≤xi≤10000000000 \le x_i \le 1000000000) and yiy_i (0≤yi≤10000000000 \le y_i \le 1000000000), the coordinates of the ii-th team. No two teams share the same coordinates.

Output

For each test case, print one line with the number of pairs of teams that sit too close to each other.

Examples1

  1. Example 1

    Input
    1
    6 3
    0 0
    0 3
    2 1
    2 3
    3 0
    3 1
    
    Expected output
    8