#include<bits/stdc++.h>
using namespace std;
const long long maxn=1010;
long long T,n,h;
long long fa[maxn];
long long x[maxn],y[maxn],z[maxn],r;
long long find(long long x)
{
if(fa[x]==x) return x;
return fa[x]=find(fa[x]);
}
int main()
{
scanf("%lld",&T);
while(T--)
{
for(long long i=1;i<=n+2;i++) fa[i]=i;
scanf("%lld %lld %lld",&n,&h,&r);
for(long long i=1;i<=n;i++)
{
scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
for(long long 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))
{
long long r1=find(i),r2=find(j);
if(r1!=r2)
fa[r1]=r2;
}
if(z[i]<=r)
{
long long r1=find(n+1),r2=find(i);
if(r1!=r2)
fa[r1]=r2;
}
if(z[i]>=h-r)
{
long long 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;
}