#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
long long x[1005],y[1005],z[1005],n,h,r;
bool beg[1005],End[1005],flag,color[1005];
long double check(int i,int j){
long double t1=x[i]-x[j];
long double t2=y[i]-y[j];
long double t3=z[i]-z[j];
return (long double)sqrt(t1*t1+t2*t2+t3*t3);
}
void dfs(int x){
color[x]=true;
if (End[x]) flag=true;
for (int i=1;i<=n;i++){
if (!color[i] && check(x,i)<=(long double)2*r)
dfs(i);
if (flag) return;
}
}
int main(){
int cas;
scanf("%d",&cas);
while (cas--){
scanf("%lld%lld%lld",&n,&h,&r);
for (int i=1;i<=n;i++)
beg[i]=End[i]=color[i]=false;
for (int i=1;i<=n;i++){
scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
if (z[i]-r<=0)
beg[i]=true;
if (z[i]+r>=h)
End[i]=true;
}
flag=false;
for (int i=1;i<=n;i++)
if (!color[i] && beg[i])
dfs(i);
if (flag)
printf("Yes\n"); else
printf("No\n");
}
return 0;
}