#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}

vector<double> solve_quadeq(double a, double b, double c){
    vector<double> ret;
    if(abs(a) < EPS){
        if(abs(b) > EPS) ret.push_back(-c/b);
        return ret;
    }
    double d = b*b -4*a*c;
    if(abs(d) < EPS) d = 0;
    if(d < 0) return ret;
    ret.push_back((-b -sqrt(d))/(2*a));
    ret.push_back((-b +sqrt(d))/(2*a));
    return ret;
}

bool epseq(const double &a, const double &b){
	return abs(a-b) < EPS;
}

struct event{
	int a,b,on;
	double time;
	event(int a, int b, int on, double t):a(a),b(b),on(on),time(t){}
	event(){}
	bool operator<(const event &a){
		return time < a.time;
	}
};

vector<event> calc_event(vector<VP> &c, int t, double r){
	int n = c.size();
	vector<event> ret;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			vector<double> times;
			if(abs(c[i][0]-c[j][0]) < r +EPS){
				times.push_back(0);	
			}
			for(int ct=0; ct<t; ct++){
				P diff = c[j][ct] -c[i][ct];
				P vdiff = (c[j][ct+1] -c[j][ct]) -(c[i][ct+1] -c[i][ct]);
				double a = norm(vdiff);
				double b = 2*dot(diff, vdiff);
				double c = norm(diff) -r*r;
				vector<double> ret = solve_quadeq(a,b,c);
				for(double t : ret){
					if(0 < t +EPS && t < 1 +EPS){
						times.push_back(ct+t);
					}
				}
			}
			sort(times.begin(), times.end());
			times.erase(unique(times.begin(), times.end(), epseq), times.end());
			int on = 0;
			for(double t : times){
				on = 1-on;
				ret.emplace_back(i, j, on, t);
			}
		}		
	}
	sort(ret.begin(), ret.end());
	return ret;
}

void dfs(int v, vector<bool> &used, vector<vector<bool> > &adj){
	if(used[v]) return;
	used[v] = true;
	for(int i=0; i<(int)adj.size(); i++){
		if(adj[v][i]) dfs(i, used, adj);
	}
}

int main(){
	while(1){
		int n,t,r;
		cin >> n >> t >> r;
		if(n == 0) break;

		vector<VP> c(n, VP(t+1));
		vector<string> name(n);
		for(int i=0; i<n; i++){
			cin >> name[i];
			int prev = 0;
			int ct,x,y;
			cin >> ct >> x >> y;
			c[i][0] = P(x, y);
			while(1){
				cin >> ct >> x >> y;
				P vec(x, y);
				for(int s=prev; s<ct; s++){
					c[i][s+1] = c[i][s] +vec;
				}
				prev = ct;
				if(ct == t) break;
			}
		}

		vector<event> info = calc_event(c, t, r);
		vector<vector<bool> > adj(n, vector<bool>(n, false));
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				if(abs(c[i][0] -c[j][0]) < r +EPS){
					adj[i][j] = adj[j][i] = true;
				}
			}
		}
		vector<bool> reach(n, false);
		reach[0] = true;
		for(event e: info){
			if(e.on == 0){
				adj[e.a][e.b] = adj[e.b][e.a] = false;
			}else{
				adj[e.a][e.b] = adj[e.b][e.a] = true;
				if(reach[e.a] != reach[e.b]){
					dfs(e.a, reach, adj);
					dfs(e.b, reach, adj);
				}
			}
		}
		vector<string> ans;
		for(int i=0; i<n; i++){
			if(reach[i]) ans.push_back(name[i]);
		}
		sort(ans.begin(), ans.end());
		for(string s: ans){
			cout << s << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4440