#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void searchAccess(const vector<vector<bool> >& graph, int start, bitset<100>& access)
{
    int n = graph.size();
    access.reset();

    access[start] = true;
    queue<int> q;
    q.push(start);
    while(!q.empty()){
        for(int i=0; i<n; ++i){
            if(graph[q.front()][i] && !access[i]){
                q.push(i);
                access[i] = true;
            }
        }
        q.pop();
    }
}

const double EPS = 1.0e-10;

int pow2(int a){
    return a*a;
}

class Point{
public:
    int y, x;
    Point(int y0, int x0){
        y = y0;
        x = x0;
    }
    int dist2(const Point& p) const{
        return pow2(y-p.y) + pow2(x-p.x);
    }
    Point operator+(const Point& p) const{
        return Point(y+p.y, x+p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y-p.y, x-p.x);
    }
    Point operator*(int a) const{
        return Point(y*a, x*a);
    }
};

vector<vector<int> > test;

int main()
{
    for(;;){
        int n, maxT, r;
        cin >> n >> maxT >> r;
        if(n == 0)
            return 0;

        vector<string> name(n);
        vector<Point> p(n, Point(0, 0));
        vector<vector<int> > t(n, vector<int>(1));
        vector<vector<Point> > v(n, vector<Point>(1, Point(0, 0)));
        for(int i=0; i<n; ++i){
            cin >> name[i] >> t[i][0] >> p[i].x >> p[i].y;
            for(;;){
                int t0, x0, y0;
                cin >> t0 >> x0 >> y0;
                t[i].push_back(t0);
                v[i].push_back(Point(y0, x0));
                if(t0 == maxT)
                    break;
            }
        }

        vector<vector<bool> > connect(n, vector<bool>(n, false));
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                if(p[i].dist2(p[j]) <= r * r)
                    connect[i][j] = connect[j][i] = true;
            }
        }
        bitset<100> check;
        searchAccess(connect, 0, check);

        multimap<double, pair<int, int> > mm;
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                Point p1 = p[i];
                Point p2 = p[j];
                unsigned k1 = 1;
                unsigned k2 = 1;
                double prevT = -1.0;
                while(k1 < v[i].size() && k2 < v[j].size()){
                    Point v1 = v[i][k1];
                    Point v2 = v[j][k2];
                    Point dp = (p1 - v1 * t[i][k1-1]) - (p2 - v2 * t[j][k2-1]);
                    Point dv = v1 - v2;
                    int a = pow2(dv.y) + pow2(dv.x);
                    int b = 2 * (dp.y * dv.y + dp.x * dv.x);
                    int c = pow2(dp.y) + pow2(dp.x) - pow2(r);
                    int d = pow2(b) - 4 * a * c;
                    if(a > 0 && d >= 0){
                        double t1 = (-b - sqrt((double)d)) / (2 * a);
                        double t2 = (-b + sqrt((double)d)) / (2 * a);
                        if(max(t[i][k1-1], t[j][k2-1]) <= t1 + EPS && t1 - EPS <= min(t[i][k1], t[j][k2]) && abs(prevT - t1) > EPS){
                            mm.insert(make_pair(t1, make_pair(i, j)));
                            prevT = t1;
                        }
                        if(max(t[i][k1-1], t[j][k2-1]) <= t2 + EPS && t2 - EPS <= min(t[i][k1], t[j][k2]) && abs(prevT - t2) > EPS){
                            mm.insert(make_pair(t2, make_pair(i, j)));
                            prevT = t2;
                        }
                    }

                    if(t[i][k1] <= t[j][k2]){
                        p1 = p1 + v1 * (t[i][k1] - t[i][k1-1]);
                        ++ k1;
                    }else{
                        p2 = p2 + v2 * (t[j][k2] - t[j][k2-1]);
                        ++ k2;
                    }
                }
            }
        }

        while(!mm.empty()){
            double t0 = mm.begin()->first;
            int a = mm.begin()->second.first;
            int b = mm.begin()->second.second;
            mm.erase(mm.begin());

            connect[a][b] = connect[b][a] = !connect[a][b];
            if(check[a] != check[b]){
                bitset<100> bs;
                searchAccess(connect, a, bs);
                check |= bs;
            }
        }

        vector<string> ret;
        for(int i=0; i<n; ++i){
            if(check[i])
                ret.push_back(name[i]);
        }
        sort(ret.begin(), ret.end());
        for(unsigned i=0; i<ret.size(); ++i)
            cout << ret[i] << endl;
    }
}

Measured memory_bytes: 0