#include <iostream>
#include<queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
typedef long long ll;
using namespace std;
const int maxn = 100000 + 10;
ll t,fa[1001],flag1=0,flag2=0;
struct node{
ll x,y,z;
}a[1001];
inline ll find(ll x){return x==fa[x]?x:fa[x]=find(fa[x]);}
inline void Union(ll x,ll y){
ll px=find(x);
ll py=find(y);
if(px!=py) fa[px]=py;
}
inline double dist(double x,double y,double z,double aa,double ba,double ca)
{
return pow((x-aa),2)+pow((y-ba),2)+pow((z-ca),2);
}
int main(){
scanf("%lld",&t);
while(t--){
flag1=0,flag2=0;
ll n,h,r;
scanf("%lld%lld%lld",&n,&h,&r);
for(ll i=1;i<=n;i++) fa[i]=i;
for(ll i=1;i<=n;i++){
scanf("%lld %lld %lld",&a[i].x,&a[i].y,&a[i].z);
ll t=a[i].z;
if(a[i].z-r<=0) flag1=1;
if(a[i].z+r>=h) flag2=1;
}
for(ll i=1;i<=n;i++){
for(ll j=1;j<=i;j++){
if(dist(a[j].x,a[j].y,a[j].z,a[i].x,a[i].y,a[i].z)<=(pow(r,2)*2))
if(find(j)!=find(i)) Union(i,j);
}
}
ll cnt=0;
for(ll i=1;i<=n;i++) if(find(i)==i) cnt++;
//cout << cnt << " " << flag1 << " " << flag2 << endl;
if(cnt==1&&flag1==1&&flag2==1) printf("Yes\n");
else printf("No\n");
}
return 0;
}