Problem: A new type of mobile robot has been developed for environmental earth observation. It moves around on the ground, acquiring and recording various sorts of observational data using high precision sensors. Robots of this type have short range wireless communication devices and can exchange observational data with ones nearby. They also have large capacity memory units, on which they record data observed by themselves and those received from others.

Figure 1 illustrates the current positions of three robots A, B, and C and the geographic coverage of their wireless devices. Each circle represents the wireless coverage of a robot, with its center representing the position of the robot. In this figure, two robots A and B are in the positions where A can transmit data to B, and vice versa. In contrast, C cannot communicate with A or B, since it is too remote from them. Still, however, once B moves towards C as in Figure 2, B and C can start communicating with each other. In this manner, B can relay observational data from A to C. Figure 3 shows another example, in which data propagate among several robots instantaneously.

<image>
---
Figure 1: The initial configuration of three robots
<image>
---
Figure 2: Mobile relaying
<image>
---
Figure 3: Instantaneous relaying among multiple robots

As you may notice from these examples, if a team of robots move properly, observational data quickly spread over a large number of them. Your mission is to write a program that simulates how information spreads among robots. Suppose that, regardless of data size, the time necessary for communication is negligible.



Input

The input consists of multiple datasets, each in the following format.

> N T R
>  nickname and travel route of the first robot
>  nickname and travel route of the second robot
>  ...
>  nickname and travel route of the N-th robot
>

The first line contains three integers N, T, and R that are the number of robots, the length of the simulation period, and the maximum distance wireless signals can reach, respectively, and satisfy that 1 <=N <= 100, 1 <= T <= 1000, and 1 <= R <= 10.

The nickname and travel route of each robot are given in the following format.

> nickname
>  t0 x0 y0
>  t1 vx1 vy1
>  t2 vx2 vy2
>  ...
>  tk vxk vyk
>

Nickname is a character string of length between one and eight that only contains lowercase letters. No two robots in a dataset may have the same nickname. Each of the lines following nickname contains three integers, satisfying the following conditions.

> 0 = t0 < t1 < ... < tk = T
>  -10 <= vx1, vy1, ..., vxk, vyk<= 10
>

A robot moves around on a two dimensional plane. (x0, y0) is the location of the robot at time 0. From time ti-1 to ti (0 < i <= k), the velocities in the x and y directions are vxi and vyi, respectively. Therefore, the travel route of a robot is piecewise linear. Note that it may self-overlap or self-intersect.

You may assume that each dataset satisfies the following conditions.

* The distance between any two robots at time 0 is not exactly R.
* The x- and y-coordinates of each robot are always between -500 and 500, inclusive.
* Once any robot approaches within R + 10-6 of any other, the distance between them will become smaller than R - 10-6 while maintaining the velocities.
* Once any robot moves away up to R - 10-6 of any other, the distance between them will become larger than R + 10-6 while maintaining the velocities.
* If any pair of robots mutually enter the wireless area of the opposite ones at time t and any pair, which may share one or two members with the aforementioned pair, mutually leave the wireless area of the opposite ones at time t', the difference between t and t' is no smaller than 10-6 time unit, that is, |t - t' | >= 10-6.


A dataset may include two or more robots that share the same location at the same time. However, you should still consider that they can move with the designated velocities.

The end of the input is indicated by a line containing three zeros.

Output

For each dataset in the input, your program should print the nickname of each robot that have got until time T the observational data originally acquired by the first robot at time 0. Each nickname should be written in a separate line in dictionary order without any superfluous characters such as leading or trailing spaces.

Example

Input

3 5 10
red
0 0 0
5 0 0
green
0 5 5
5 6 1
blue
0 40 5
5 0 0
3 10 5
atom
0 47 32
5 -10 -7
10 1 0
pluto
0 0 0
7 0 0
10 3 3
gesicht
0 25 7
5 -7 -2
10 -1 10
4 100 7
impulse
0 -500 0
100 10 1
freedom
0 -491 0
100 9 2
destiny
0 -472 0
100 7 4
strike
0 -482 0
100 8 3
0 0 0


Output

blue
green
red
atom
gesicht
pluto
freedom
impulse
strike

Solution (in CPP):

Solution:
#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-7)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pow2(a) ((a)*(a))

using namespace std;

typedef pair<double,double> dd;
const int MAX_N = 110;
const double DINF = 1e20;

int N,T,R;
int size[MAX_N];
double x[MAX_N][1100],y[MAX_N][1100],tmp_x[MAX_N],tmp_y[MAX_N],vx[MAX_N][1100],vy[MAX_N][1100],t[MAX_N][1100];
string nickname[MAX_N];
bool knows[MAX_N];

bool LT(double a ,double b){ return !equals(a,b) && a < b; }
bool LTE(double a,double b){ return  equals(a,b) || a < b; }

double getDist(double X,double Y){ return sqrt( X*X + Y*Y ); }

dd calc(double x1,double y1,double vx1,double vy1,
        double x2,double y2,double vx2,double vy2,double r){
  double VX = (vx1-vx2), X = (x1-x2), VY = (vy1-vy2), Y = (y1-y2);
  double a = pow2(VX) + pow2(VY), b = 2*(X*VX+Y*VY), c = pow2(X) + pow2(Y) - pow2(r);
  dd ret = dd(DINF,DINF);
  double D = b*b - 4 * a * c;

  if( LT(D,0.0) ) return ret;

  if( equals(a,0.0) ) {
    if( equals(b,0.0) ) return ret;
    if( LT(-c/b,0.0)  ) return ret;
    ret.first = - c / b;
    return ret;
  }

  if( equals(D,0.0) ) D = 0;
  ret.first  = ( -b - sqrt( D ) ) / ( 2 * a );
  ret.second = ( -b + sqrt( D ) ) / ( 2 * a );
  if( !equals(ret.first,ret.second) && ret.first > ret.second ) swap(ret.first,ret.second);
  return ret;
}

int par[1000];

void init(){ rep(i,N) par[i] = i; } 

int find(int x){
  if( x==par[x])return par[x];
  return par[x] = find(par[x]);
}

void unit(int x,int y){
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}

inline void compute2(){
  int cur[N];
  rep(i,N) knows[i] = false, cur[i] = 0;
  knows[0] = true;

  double cx[N], cy[N];
  rep(i,N) cx[i] = x[i][0], cy[i] = y[i][0];

  init();
  rep(i,N) REP(j,i+1,N) {
    double dist = getDist(x[i][0]-x[j][0],y[i][0]-y[j][0]);
    if( LTE(dist,R) ) unit(i,j);
  }
  REP(i,1,N) if( find(0) == find(i) ) knows[i] = true;

  deque<double> time_stamp;
  double prev = 0;
  rep(i,N) rep(j,size[i]) if( t[i][j] != 0 ) time_stamp.push_back(t[i][j]);
  sort(time_stamp.begin(),time_stamp.end());
  time_stamp.erase(unique(time_stamp.begin(),time_stamp.end()),time_stamp.end());  
  while( 1 ){
    double mini = 1e10;
    rep(i,N) REP(j,i+1,N) {
      if( cur[i]+1 >= size[i] || cur[j]+1 >= size[j] ) continue;
      if( knows[i] + knows[j] != 1 ) continue;
      dd res = calc(cx[i],cy[i],vx[i][cur[i]+1],vy[i][cur[i]+1],
                    cx[j],cy[j],vx[j][cur[j]+1],vy[j][cur[j]+1],R);
        
      double lower = max(t[i][cur[i]],t[j][cur[j]]);
      double upper = min(t[i][cur[i]+1],t[j][cur[j]+1]);
      assert( LTE(lower,prev) && LTE(prev,upper) );
      if( LTE(0.0,res.first) ){
        if( LTE(lower,prev+res.first)  && LTE(prev+res.first,upper) )  mini = min(mini,prev+res.first);
      }

      if( LTE(0.0,res.second) ){
        if( LTE(lower,prev+res.second) && LTE(prev+res.second,upper) ) mini = min(mini,prev+res.second);
      }
    }

    bool initer = false;
    if( !time_stamp.empty() && LTE(time_stamp.front(),mini) ) {
      mini = time_stamp.front();
      time_stamp.pop_front();
      initer = true;
    }

    if( equals(mini,1e10) ) break;

    double tm = mini;
    
    rep(j,N){
      cx[j] += vx[j][cur[j]+1] * (tm-prev);
      cy[j] += vy[j][cur[j]+1] * (tm-prev);
    }

    init();
    rep(j,N) if( knows[j] ) unit(0,j);

    rep(j,N)REP(k,j+1,N) {
      if( size[j] <= cur[j]+1 || size[k] <= cur[k]+1 ) continue;
      if( !( LTE(t[j][cur[j]],tm) && LTE(tm,t[j][cur[j]+1]) ) ) continue;
      if( !( LTE(t[k][cur[k]],tm) && LTE(tm,t[k][cur[k]+1]) ) ) continue;
      double dist = getDist(cx[j]-cx[k],cy[j]-cy[k]);
      if( LTE(dist,R) ) unit(j,k);
    }
    REP(j,1,N) if( find(0) == find(j) ) knows[j] = true;
    rep(i,N) if( cur[i]+1 < size[i] && equals(mini,t[i][cur[i]+1]) ) cur[i]++;
    prev = mini;
  }

  vector<string> vec;
  rep(i,N) if( knows[i] ) vec.push_back(nickname[i]);
  if(!vec.empty())sort(vec.begin(),vec.end());
  rep(i,vec.size()) cout << vec[i] << endl;

}

int main(){
  while( scanf("%d%d%d",&N,&T,&R), N|T|R ){
    rep(i,N){
      cin >> nickname[i];
      cin >> t[i][0] >> x[i][0] >> y[i][0];
      vx[i][0] = vy[i][0] = 0;
      size[i] = 1;
      while( cin >> t[i][size[i]] ){
        cin >> vx[i][size[i]] >> vy[i][size[i]];
        x[i][size[i]] = x[i][size[i]-1] + vx[i][size[i]] * ( t[i][size[i]] - t[i][size[i]-1] );
        y[i][size[i]] = y[i][size[i]-1] + vy[i][size[i]] * ( t[i][size[i]] - t[i][size[i]-1] );
        ++size[i];
        if( t[i][size[i]-1] == T ) break;
      }
    }
    compute2();    
  }
  return 0;
}