#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
int T,n,h;
int fa[maxn];
long long x[maxn],y[maxn],z[maxn],r;
int find(int x)
{
if(fa[x]==x) return x;
return fa[x]=find(fa[x]);
}
int main()
{
scanf("%d",&T);
while(T--)
{
for(int i=1;i<=n+2;i++) fa[i]=i;
scanf("%d %d %lld",&n,&h,&r);
for(int i=1;i<=n;i++)
{
scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
for(int j=1;j<i;j++)
if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])<=(r*r*4ll))
{
int r1=find(i),r2=find(j);
if(r1!=r2)
fa[r1]=r2;
}
if(z[i]<=r)
{
int r1=find(n+1),r2=find(i);
if(r1!=r2)
fa[r1]=r2;
}
if(z[i]>=h-r)
{
int r1=find(n+2),r2=find(i);
if(r1!=r2)
fa[r1]=r2;
}
}
if(find(n+1)==find(n+2)) printf("Yes\n");
else printf("No\n");
}
return 0;
}