#include <bits/stdc++.h>
using namespace std;
int t, n, h, r;
struct node{
int x, y, z;
}ar[1010];
bool dis(node a, node b, int R) {
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) <= 4 * R * R;
}
bool vis[1010];
int main() {
cin >> t;
while (t--) {
cin >> n >> h >> r;
queue <int> q;
for (int i = 1; i <= n; i++) vis[i] = 0;
for (int i = 1; i <= n; i++) {
cin >> ar[i].x >> ar[i].y >> ar[i].z;
if (ar[i].z <= r) {
q.push(i);
vis[i] = 1;
}
}
bool flag = false;
while (!q.empty()) {
int j = q.front();
q.pop();
if (h - ar[j].z <= r) {
cout << "Yes" << endl;
flag = true;
break;
}
for (int i = 1; i <= n; i++) {
if (vis[i]) continue;
if (dis(ar[j], ar[i], r)) {
vis[i] = 1;
q.push(i);
}
}
}
if (!flag) cout << "No" << endl;
}
return 0;
}