// Arup Guha
// 1/18/2017
// Solution to 2014 NAQ Problem G: Pesky Mosquitos

import java.util.*;

public class mosquitos {

	public static double radius;
	public static int n;
	public static pt[] list;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<numCases; loop++) {

			// Read in the input.
			n = stdin.nextInt();
			radius = stdin.nextDouble()/2;
			list = new pt[n];
			for (int i=0; i<n; i++) {
				double x = stdin.nextDouble();
				double y = stdin.nextDouble();
				list[i] = new pt(x,y);
			}

			int res = 1;

			// Try pts i and j on circumference of circle with radius r.
			for (int i=0; i<n; i++) {
				for (int j=i+1; j<n; j++) {

					// These two can't be on the same circle of radius r.
					if (list[i].dist(list[j]) > 2*radius + 1e-9) continue;

					// Get the two possible centers of the circle that contain these two points
					// on their circumference.
					pt[] centers = getCenters(i, j);

					// Update result if placing the bowl here helps.
					for (int k=0; k<centers.length; k++)
						res = Math.max(res, cover(centers[k]));
				}
			}

			// Output the result.
			System.out.println(res);
		}
	}

	// Just see how many pts are within radius of center.
	public static int cover(pt center) {
		int res = 0;
		for (int i=0; i<n; i++)
			if (center.dist(list[i]) <= radius +1e-9)
				res++;
		return res;
	}

	public static pt[] getCenters(int cI, int cJ) {

		// Get midpoint of list[cI], list[cJ] and then 2 perpendicular vectors.
		pt mid = list[cI].midpt(list[cJ]);
		pt vector = list[cI].getVector(list[cJ]);
		pt[] perp = vector.getUnitPerp();

		double leg = list[cI].dist(list[cJ])/2;
		double sq = radius*radius - leg*leg;
		double factor = Math.sqrt(sq);

		// Only 1 pt here.
		if (Math.abs(sq) < 1e-9) {
			pt[] res = new pt[1];
			res[0] = mid;
			return res;
		}

		// 2 pt case.
		else {
			pt[] res = new pt[2];
			for (int i=0; i<2; i++)
				res[i] = mid.add(perp[i].mult(factor));
			return res;
		}
	}
}

// Standard class to manage 2D vector geometry. It does both pts and vectors.
class pt {

	public double x;
	public double y;

	public pt(double myx, double myy) {
		x = myx;
		y = myy;
	}

	public pt mult(double c) {
		return new pt(c*x, c*y);
	}

	public pt add(pt other) {
		return new pt(x+other.x, y+other.y);
	}

	public double mag() {
		return Math.sqrt(x*x+y*y);
	}

	public pt midpt(pt other) {
		return new pt((x+other.x)/2, (y+other.y)/2);
	}

	public pt getVector(pt other) {
		return new pt(other.x-x, other.y-y);
	}

	// Returns both vectors perpendicular to this.
	public pt[] getUnitPerp() {
		double div = mag();
		pt[] res = new pt[2];
		res[0] = new pt(this.y/div, -this.x/div);
		res[1] = new pt(-this.y/div, this.x/div);
		return res;
	}

	public double dist(pt other) {
		return Math.sqrt((x-other.x)*(x-other.x) + (y-other.y)*(y-other.y) );
	}
}