import java.util.Scanner;
public class cheese {
static int nn;
static int[] father;
static class State{
int x;
int y;
int z;
public State(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
}
public static int find(int x){
if(father[x]!=x){
father[x]=find(father[x]);
}
return father[x];
}
public static boolean isjin(State s1,State s2,int r){
double num=Math.pow(s1.x-s2.x,2)+Math.pow(s1.y-s2.y,2)+Math.pow(s1.z-s2.z,2);
double num2=4*Math.pow(r,2);
if(num<=num2){
return true;
}
return false;
}
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
for(int i=0;i<n;i++){
nn=in.nextInt();
father=new int[nn+2];
int h=in.nextInt();
int r=in.nextInt();
State[] arr=new State[nn];
for(int j=0;j<nn;j++){
int x=in.nextInt();
int y=in.nextInt();
int z=in.nextInt();
State s=new State(x,y,z);
arr[j]=s;
}
for(int j=0;j<=nn+1;j++){
father[j]=j;
}
for(int j=1;j<=nn;j++){
for(int k=j+1;k<=nn;k++){
if(isjin(arr[j-1],arr[k-1],r)){
father[find(j)]=find(k);
}
}
}
for(int j=1;j<=nn;j++){
if(arr[j-1].z<=r){
father[find(j)]=find(0);
}
}
for(int j=1;j<=nn;j++){
if(Math.abs(arr[j-1].z-h)<=r){
father[find(j)]=find(nn+1);
}
}
if(find(0)==find(nn+1)){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
}