#pragma GCC target("f16c")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC optimize(3)
// luogu-judger-enable-o2
#include<cstdio>
struct Node{
long long x,y,z;
}ho[1010];
long long n,h,r;
bool ans;
int f[1010],b1[1010],b2[1010];
inline long long read()
{
long long x=0;int k=1;char c=getchar();
while(c<'0')k^=(c=='-'),c=getchar();
while(c>='0')x=(x<<3)+(x<<1)+(c^48),c=getchar();
return k?x:-x;
}
inline long long dist(Node a,Node b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z);
}
inline int find(int x)
{
return f[x]==x?x:f[x]=find(f[x]);
}
int main()
{
register int x,y;
register long long t=read();
while(t--)
{
ans=false;
n=read(),h=read(),r=read();
for(register int i=1;i<=n;i++)
f[i]=i,b1[i]=0,b2[i]=0;
for(register int i=1;i<=n;i++)
ho[i].x=read(),ho[i].y=read(),ho[i].z=read();
for(register int i=1;i<=n;i++)
{
for(register int j=1;j<i;j++)
{
if(dist(ho[i],ho[j])<=2*r*2*r)
{
x=find(i),y=find(j);
if(x!=y)
f[x]=y;
}
}
}
for(register int i=1;i<=n;i++)
if(ho[i].z>=h-r)
b1[i]=1;
for(register int i=1;i<=n;i++)
if(ho[i].z<=r)
b2[i]=1;
for(register int i=1;i<=n;i++)
for(register int j=1;j<=n;j++)
if(b1[i]&&b2[j]&&find(f[i])==find(f[j]))
{
ans=true;
break;
}
puts(ans?"Yes":"No");
}
return 0;
}