Each test consists of several test cases. The first line contains a single integer $t$ ($1 \le t \le 1\,000$)~--- the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $n$ and $r$ ($3 \le n \le 2\,000$, $1 \le r \le 10^9$)~--- the number of points and the maximum distance for moving a point.

The next $n$ lines describe the points. The $i$-th line contains three integers $x_i$, $y_i$, and $c_i$ ($-10^9 \le x_i, y_i \le 10^9$, $1 \le c_i \le 2$)~--- the coordinates and color of point $i$ (1 ~--- white, 2 ~--- black).

It is guaranteed that the sum of $n$ over all test cases in each test does not exceed $2\,000$.