#include<bits/stdc++.h>
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;

const double EPS = 1e-9;
const double INF = 1e100;

namespace std {
  bool operator < (const P& a, const P& b ) {
    return fabs( real(a) - real(b) ) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
  bool operator == (const P& a, const P& b ) {
    return fabs( real(a) - real(b) ) < EPS && fabs(imag(a) - imag(b)) < EPS;
  }
};

double dot(P a,P b){ return a.real() * b.real() + a.imag() * b.imag(); }
double cross(P a,P b){ return a.real() * b.imag() - a.imag() * b.real(); }

P proj(P p, L l){
    return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);
}

double getDistanceSP(L s, P p){
  if(dot(s.second - s.first, p - s.first) < -EPS) return abs(p - s.first);
  if(dot(s.first - s.second, p - s.second) < -EPS) return abs(p - s.second);
  return abs(cross(s.second - s.first, p - s.first) / abs(s.second - s.first));
}

bool isParallel( L l, L m){
  P v1 = l.first - l.second;
  P v2 = m.first - m.second;
  v1 /= abs(v1);
  v2 /= abs(v2);
  if( v1 == v2 ) return true;
  v1 *= -1;
  if( v1 == v2 ) return true;
  return false;
}

P crossPoint(L l, L m){
  if( isParallel(l,m) ) return P(INF,INF);
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
  assert(false);
  return P(INF,INF);
}

P reflect(P p, L l){
  return p + (proj(p,l) - p) * 2.0;
}
int N;
double W,H,R;
double MAXLEN = 10000.0;

double dx[]={0,1,0,-1};
double dy[]={-1,0,1,0};
int touchLine(L l, L *ds,int stid){
  double mini = INF;
  int id = -1;
  for(int j=0;j<2;j++){
    int i=(stid+j)%4;
    P ps = crossPoint(l,ds[i]);
    if( mini > abs( ps - l.first ) ){
      id = i; mini = abs( ps - l.first );
    }
  }
  assert(id!=-1);
  return id;
}

vector<P> vcs;

void rev(vector<P> cs,L *ds,int stid){
  for(int k=0;k<2;k++){
    L s = ds[(stid+k)%4];
    for(int i=0;i<N;i++)
      vcs.push_back( reflect( cs[i], s ) );    
  }
}
void rev(vector<P> &cs,L s){
  for(int i=0;i<N;i++)
    cs[i] = reflect( cs[i], s );    
}

void cloneP(L l,vector<P> cs,int stid){  
  L ds[4]={ L(P(R,R),P(W-R,R)), L(P(W-R,R),P(W-R,H-R)), L(P(W-R,H-R),P(R,H-R)), L(P(R,H-R),P(R,R)) };
  vcs.clear();
  for(int i=0;i<N;i++) vcs.push_back( cs[i] );
  for(int i=0;i<40;i++){
    int tl = touchLine(l,ds,stid);
    //rev(cs, ds, stid);
    rev(cs, ds[tl] );
    //cout << "view" << endl;
    //cout << tl << " " << ds[tl].first << " - " << ds[tl].second << endl;
    ds[tl] = L( P( ds[tl].first.real() + (W-2*R) * dx[tl], ds[tl].first.imag() + (H-2*R) * dy[tl] ),
                P( ds[tl].second.real() + (W-2*R)* dx[tl], ds[tl].second.imag() + (H-2*R)* dy[tl] ) );
    //for(int i=0;i<N;i++)cout<< cs[i] << endl;
    for(int i=0;i<N;i++) vcs.push_back( cs[i] );    
  }
}

vector<P> getRadiusPoint( L s, P p, double r ){
  P sp = proj( p, s );
  P v = s.first-s.second;
  v/=abs(v);
  double x = abs(p-sp);
  double k = sqrt(r*r - x*x);
  vector<P> res;
  //cout << "getR " << sp << endl;
  if(k<EPS){
    res.push_back( sp );
    return res;
  }
  //cout << sp << " " << v << " "  << k << endl;
  res.push_back( sp + v * k );
  res.push_back( sp - v * k );
  return res;
}

int main(){
  int tcase=0;
  while( cin >> N && N ){
    tcase++;
    int x,y;
    cin >> W >> H >> R >> x >> y;
    P vs = P(x,y);
    cin >> x >> y;
    P ps; ps = P(x,y); N--;
    
    vector<P> c;
    for(int i=0;i<N;i++){
      cin >> x >> y;
      c.push_back( P( x,y ) );
    }        
    int stid=-1;
    if( vs.real() > 0 ){
      if( vs.imag() > 0 ) stid=1;
      else stid = 0;
    } else {
      if( vs.imag() > 0 ) stid=2;
      else stid=3;
    }

    assert(stid!=-1);
    cloneP( L( ps, ps + vs ), c, stid );    
    vs=vs*MAXLEN/abs(vs);    
    L s = L( ps, ps + vs );
    vector<P> tps;
    vector<int> tpid;

    //cout << N << endl;
    for(int i=0;i<(int)vcs.size();i++){     
      //cout << vcs[i] << endl;
      if( getDistanceSP( s, vcs[i] ) < R*2.0+EPS ){      
        // cout << "in " << vcs[i] << endl;
        vector<P> rp = getRadiusPoint( s, vcs[i], R*2.0 );
        for(int j=0;j<(int)rp.size();j++){
          tps.push_back( rp[j] );
          tpid.push_back( i );
        }
      }
    }
    double mini = INF;
    int id = -3;
    for(int i=0;i<(int)tps.size();i++){
      //cout << tpid[i]%N << " " << tps[i] << " " << abs(ps-tps[i]) << endl;
      if( mini > abs( ps - tps[i] ) ){
        mini = abs( ps - tps[i] );
        id = tpid[i]%N;        
      }
    }
    cout << id+2 << endl;
  }
}

Measured memory_bytes: 1296