#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;

#define repi(i,j,n) for (int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define INF 1e9

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define PI acos(-1)
#define rad(t) double(t)*PI/180.0

// Geometry short ver

class P {
public:
    double x, y;
    P(double x = 0.0, double y = 0.0) : x(x), y(y) {}

    P operator + (P p) {
        return P(x + p.x, y + p.y);
    }
    P operator - (P p) {
        return P(x - p.x, y - p.y);
    }
    P operator * (double c) {
        return P(c * x, c * y);
    }
    P operator / (double c) {
        return P(x / c, y / c);
    }
    bool operator < (const P &p) const {
        return (x != p.x ? x < p.x : y < p.y);
    }
    bool operator == (const P &p) const {
        return (fabs(x - p.x) < EPS && fabs(y - p.y) < EPS);
    }

    double norm() {
        return (x * x + y * y);
    }

    double abs() {
        return sqrt(norm());
    }
};

typedef P V;

double dot(V a, V b) {
    return (a.x * b.x + a.y * b.y);
}

double cross(V a, V b) {
    return (a.x * b.y - a.y * b.x);
}

double norm(V a) {
    return (a.x * a.x + a.y * a.y);
}

double abs(V a) {
    return sqrt(norm(a));
}

class S {
public:
    P s, e; // start, end
    S(P s = P(), P e = P()) : s(s), e(e) {}
};

typedef S L;

typedef vector<P> Polygon;

double dP(P a, P b) {
    return (a - b).abs();
}

double dL(L l, P p) {
    return abs(cross(l.e - l.s, p - l.s) / abs(l.e - l.s));
}

double dS(S s, P p) {
    if (dot(s.e - s.s, p - s.s) < 0.0) return abs(p - s.s);
    if (dot(s.s - s.e, p - s.e) < 0.0) return abs(p - s.e);
    return dL(s, p);
}

const int CCW = 1, CW = -1, OB = 2, OF = -2, OS = 0;

int ccw(P x, P y, P z) {
    V a = y - x, b = z - x;

    if (cross(a, b) > EPS) return CCW;
    if (cross(a, b) < -EPS) return CW;
    if (dot(a, b) < -EPS) return OB;
    if (a.norm() < b.norm()) return OF;
    return OS;
}

bool intersect(P a, P b, P c, P d) {
    return (ccw(a, b, c) * ccw(a, b, d) <= 0 && ccw(c, d, a) * ccw(c, d, b) <= 0);
}

bool intersect(S a, S b) {
    return intersect(a.s, a.e, b.s, b.e);
}

double dSS(S a, S b) {
    if (intersect(a, b)) return 0.0;
    return min(min(dS(a, b.s), dS(a, b.e)), min(dS(b, a.s), dS(b, a.e)));
}

P crossP(S a, S b) {
    V base = b.e - b.s;
    double d1 = abs(cross(base, a.s - b.s));
    double d2 = abs(cross(base, a.e - b.s));
    double t = d1 / (d1 + d2);
    return a.s + (a.e - a.s) * t;
}

/* IN 2, ON 1, OUT 0*/
int contains(Polygon g, P p) {
    int n = g.size();
    bool x = false;
    for (int i = 0; i < n; ++i) {
        P a = g[i] - p, b = g[(i + 1) % n] - p;
        if (abs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1;
        if (a.y > b.y) swap(a, b);
        if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) x = !x;
    }
    return (x ? 2 : 0);
}


Polygon andrewScan(Polygon s) {
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());

    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size() - 1]);
    l.push_back(s[s.size() - 2]);

    int ssize = s.size();

    // upper
    for (int i = 2; i < ssize; ++i) {
        for (int n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == CCW; n--) {
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    // lower
    for (int i = ssize - 3; i >= 0; i--) {
        for (int n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == CCW; n--) {
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (int i = u.size() - 2; i >= 1; i--) {
        l.push_back(u[i]);
    }

    return l;
}

// building
class B {
public:
    int n, h;
    Polygon p;
    vector<S> s;
};

int n;
int nv, h, sx, sy, tx, ty;
double x, y;
double wf[110][110];
int th, ps;
double ans;
Polygon p;
vector<B> b;

inline void makeConvexHull() {
    int size_;

    rep(i,n) {
        size_ = b[i].p.size();
        rep(j,size_) {
            b[i].p.push_back(P(b[i].p[j].x + b[i].h * cos(rad(th + 180.0)) / tan(rad(ps)),
                               b[i].p[j].y + b[i].h * sin(rad(th + 180.0)) / tan(rad(ps))));
        }

        b[i].p = andrewScan(b[i].p);
        size_ = b[i].p.size();

        rep(j,size_) {
            b[i].s.push_back(S(b[i].p[j], b[i].p[(j + 1) % size_]));
        }
    }
}

inline double solve() {
    makeConvexHull();

    int sizei, sizej;
    double mi, tmp;

    rep(i,n) {
        repi(j,i+1,n) {
            sizei = b[i].s.size();
            sizej = b[j].s.size();
            mi = INF;

            rep(k,sizei) {
                rep(l,sizej) {
                    tmp = dSS(b[i].s[k], b[j].s[l]);
                    mi = min(mi, tmp);
                    if (mi == 0) break;
                }
                if (mi == 0) break;
            }

            wf[i + 1][j + 1] = wf[j + 1][i + 1] = mi;
        }
    }

    // P(sx, sy)
    rep(i,n) {
        mi = INF;
        if (contains(b[i].p, P(sx, sy)) != 0) {
            wf[0][i + 1] = wf[i + 1][0] = 0.0;
        }
        else {
            sizei = b[i].s.size();
            rep(j,sizei) {
                tmp = dS(b[i].s[j], P(sx, sy));
                mi = min(mi, tmp);
                if (mi == 0) break;
            }
            wf[0][i + 1] = wf[i + 1][0] = mi;
        }
    }

    // P(tx, ty)
    rep(i,n) {
        mi = INF;
        if (contains(b[i].p, P(tx, ty)) != 0) {
            wf[n + 1][i + 1] = wf[i + 1][n + 1] = 0.0;
        }
        else {
            sizei = b[i].s.size();
            rep(j,sizei) {
                tmp = dS(b[i].s[j], P(tx, ty));
                mi = min(mi, tmp);
                if (mi == 0) break;
            }
            wf[n + 1][i + 1] = wf[i + 1][n + 1] = mi;
        }
    }

    // distance from P(sx, xy) to P(tx, ty)
    wf[0][n + 1] = wf[n + 1][0] = dP(P(sx, sy), P(tx, ty));

    // wf
    rep(k,n+2) {
        rep(i,n+2) {
            rep(j,n+2) {
                wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
            }
        }
    }

    return wf[0][n+1];
}

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

    while (cin >> n, n) {
        b.resize(n);
        rep(i,n+2) {
            rep(j,n+2) {
                if (i == j) wf[i][j] = 0;
                else wf[i][j] = INF;
            }
        }

        rep(i,n) {
            cin >> nv >> h;

            p.resize(nv);
            b[i].n = nv;
            b[i].h = h;

            rep(j,nv) {
                cin >> x >> y;
                p[j] = P(x, y);
            }

            b[i].p = p;
            p.clear();
        }
        cin >> th >> ps;
        cin >> sx >> sy >> tx >> ty;


        ans = solve();

        cout << fixed << setprecision(10) << ans << endl;
        b.clear();
    }
    return 0;
}