#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
int n,h,r,T,fa[maxn];
struct b{
long long int x,y,z;
}bl[maxn];
inline int find(int x){
return x==fa[x]?x:fa[x]=find(fa[x]);
}
bool cmp(b x,b y){
return x.z>y.z;
}
inline void Init(){
scanf("%d",&T);
}
inline void Work(){
while(T--){
scanf("%d%d%d",&n,&h,&r);
for(int i=1;i<=n;i++){
scanf("%lld%lld%lld",&bl[i].x,&bl[i].y,&bl[i].z);
}
memset(fa,0x3f,sizeof(fa));
for(int i=1;i<=n;i++)fa[i]=i;
fa[0]=0;fa[n+1]=n+1;
sort(bl+1,bl+n+1,cmp);
for(int i=1;i<=n;i++){
if(h-bl[i].z<=r)fa[find(i)]=fa[0];
if(bl[i].z<=r)fa[find(n+1)]=fa[find(i)];
for(int j=i+1;bl[i].z-bl[j].z<=2*r&&j<=n;j++){
if(bl[j].y-bl[i].y<=2*r&&bl[j].x-bl[j].x<=2*r)
fa[find(j)]=fa[find(i)];
}
}
if(fa[find(n+1)]==fa[find(0)])printf("Yes\n");
else printf("No\n");
}
}
int main(){
Init();
Work();
return 0;
}