#include<iostream>
#include<vector>
#define int long long
using namespace std;
#define MAXN 1001
int f[MAXN];
class node {
public:
int x, y, z,r;
node() {};
node(int x, int y, int z,int r) {
this->x = x; this->y = y; this->z = z; this->r = r;
}
bool check(node& a) {
if ((x - a.x) * (x - a.x) + (y-a.y) * (y-a.y) + (z-a.z) * (z-a.z) <= (r+a.r)*(r+a.r)) {
return true;
}
return false;
}
};
void build(int n) {
for (int i = 0; i <= n; i++) {
f[i] = i;
}
}
int find(int x) {
if (x != f[x]) {
f[x] = find(f[x]);
}
return f[x];
}
void merge(int x, int y) {
int fx = find(x);
int fy = find(y);
if (fx != fy) {
f[fx] = fy;
}
}
void solve() {
int n, h, r;
cin >> n >> h >> r;
build(n);
vector<node>a(n+2);
node e(0, 0, 0, 0); node f(0, 0, h, 0);
a[0] = e; a[n + 1] = f;
for (int i = 1; i <= n; i++) {
cin >> a[i].x >> a[i].y >> a[i].z;
a[i].r = r;
}
for (int i = 0; i <= n+1; i++) {
for (int j = i + 1; j <= n+1; j++) {
if (a[i].check(a[j])) {
merge(i, j);
}
}
}
if (find(0) == find(n + 1)) {
cout << "Yes\n";
}
else {
cout << "No\n";
}
}
signed main() {
int t; cin >> t;
while (t--) {
solve();
}
return 0;
}