#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

int sgn(double a, double b = 0) {
    return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;
}

P readP() {
    double x, y;
    cin >> x >> y;
    return P(x, y);
}

struct L {
    P a, b, v, h;
    L(){}
    L(P _a, P _b) : a(_a), b(_b), v(b - a), h(v / abs(v) * P(0, 1)) {}
    L(double _ax, double _ay, double _bx, double _by) : L(P(_ax, _ay), P(_bx, _by)) {}
    void trans(double d) {
        a += d * h;
        b += d * h;
    }
    void print() {
        cerr << "{(" << a.real() << ", " << a.imag() << "), (" << b.real() << ", " << b.imag() << ")}" << endl;
    }
};

struct C {
    P p;
    double r;
    C(){}
    C(P _p, double _r) : p(_p), r(_r) {}
    C(double _x, double _y, double _r) : p(_x, _y), r(_r) {}
    void print() {
        cerr << p.real() << " " << p.imag() << " " << r << endl;
    }
};

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

int ccw(P p0, P p1, P p2) {
    p1 -= p0; p2 -= p0;
    if (sgn(cross(p1, p2)) == 1) return +1;         // counter-clockwise
    if (sgn(cross(p1, p2)) == -1) return -1;        // clockwise
    if (sgn(dot(p1, p2)) == -1) return +2;          // p2 -- p0 -- p1
    if (sgn(norm(p1), norm(p2)) == -1) return -2;   // p0 -- p1 -- p2
    return 0;                                       // p0 -- p2 -- p1
}

// include endpoints ("<=")
bool intersectSS(L l1, L l2) {
    return (ccw(l1.a, l1.b, l2.a) * ccw(l1.a, l1.b, l2.b) <= 0 &&
            ccw(l2.a, l2.b, l1.a) * ccw(l2.a, l2.b, l1.b) <= 0);
}

P crosspointSS(L l1, L l2) {
    assert(intersectSS(l1, l2));
    double d1 = abs(cross(l2.v, l1.a - l2.a));
    double d2 = abs(cross(l2.v, l1.b - l2.a));
    double t = d1 / (d1 + d2);
    return l1.a + t * l1.v;
}

double distanceLP(L l, P p) {
    return abs(cross(l.v, p - l.a)) / abs(l.v);
}

double distanceSP(L l, P p) {
    if (sgn(dot(l.v, p - l.a)) == -1) return abs(p - l.a);
    if (sgn(dot(-l.v, p - l.b)) == -1) return abs(p - l.b);
    return distanceLP(l, p);
}

// exclude endpoints
bool intersectSC(L s, C c) {
    return sgn(distanceSP(s, c.p), c.r) == -1;
}

bool intersectPL(P p, L l) {
    return abs(ccw(l.a, l.b, p)) != 1;
}

// Assume that there are two crosspoints
vector<P> crosspointLC(L l, C c) {
    double d = distanceLP(l, c.p);
    double len = sqrt(c.r * c.r - d * d);
    P h = l.h * d;
    if (!intersectPL(c.p + h, l)) h *= -1;
    assert(intersectPL(c.p + h, l));

    vector<P> ret;
    if (intersectPL(c.p + h + l.v / abs(l.v) * len, l)) ret.emplace_back(c.p + h + l.v / abs(l.v) * len);
    if (intersectPL(c.p + h - l.v / abs(l.v) * len, l)) ret.emplace_back(c.p + h - l.v / abs(l.v) * len);
    return ret;
}

int solve(int n) {
    double w, h, r;
    cin >> w >> h >> r;
    P v = readP();  // direction
    v /= abs(v);
    P p = readP();  // position
    vector<C> circles;
    rep(i, n - 1) {
        double x, y;
        cin >> x >> y;
        circles.emplace_back(x, y, 2 * r);
    }

    vector<L> rect;
    rect.emplace_back(r, r, w - r, r);
    rect.emplace_back(w - r, r, w - r, h - r);
    rect.emplace_back(w - r, h - r, r, h - r);
    rect.emplace_back(r, h - r, r, r);

    double d = 0;
    const double MAX = 1e4;
    int hoge = 0;
    set<int> pre_used;
    while (d <= MAX) {
        L s = L(p, p + v * MAX); // half-line
        P c;
        set<int> used;
        rep(k, 4) {
            if (!pre_used.count(k) && intersectSS(s, rect[k])) {
                used.insert(k);
                if (k & 1)  v = P(-v.real(), v.imag());
                else        v = P(v.real(), -v.imag());
                c = crosspointSS(s, rect[k]);
            }
        }

        s = L(p, c); // segment
        double t = INF;
        int id = -1;
        rep(i, circles.size()) {
            if (intersectSC(s, circles[i])) {
                // cerr << "hey!" << endl;
                auto csc = crosspointLC(s, circles[i]);
                for (auto cp : csc) {
                    double d_p_cp = abs(cp - p);
                    if (t > d_p_cp && d + d_p_cp <= MAX) {
                        t = d_p_cp;
                        id = i;
                    }
                }
            }
        }

        if (id != -1) {
            return id + 2;
        }

        p = c;
        d += abs(s.b - s.a);
        pre_used = used;
    }

    return -1;
}

main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int testcase = 0;
    int n;
    while (cin >> n, n) {
        cout << solve(n) << endl;
    }
}

Measured memory_bytes: 3180