#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define L long long int

int check1(L x1,L y1,L x2,L y2,L k){
  L a,b;
  a= (x2 -x1);
  b = (y2-y1);
  if(a<0){
    a = -1*a;
  }
  if(b<0){
    b= -1*b;
  }
  L c;
  c =a+b;
  if(c <= k){
    return 1;
  }
  else{
    return 0;
  }


}


int main(){
  L t;
  cin >>t;

  for (size_t j = 0; j < t; j++) {
    L n,p;
    cin >>n>>p;

    L check=0;

    std::vector<L> x(n);
    std::vector<L> y(n);

    for (size_t i = 0; i < n; i++) {
      cin >> x[i] >> y[i];

    }

    L try1;

    for (size_t i = 0; i < n; i++) {

      try1 = 0;

      for (size_t k = 0; k < n; k++) {

        if(check1(x[i],y[i],x[k],y[k],p)){
          try1 ++;
        }
        else{
          break;
        }
      }
      if( try1 == n){
        cout << "1" << endl;
        check =1;
        break;
      }
    }
    if(check == 0){
      std::cout << "-1" << '\n';
    }
  }





  return 0;
}
