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

using ld = long double;

constexpr ld eps = 1e-8;
constexpr ld pi = acos(-1);

namespace geometry2d {


using point = std::complex<long double>;
using polygon = std::vector<point>;


bool eq(long double a, long double b) {
    return (std::abs(a-b) < eps);
}

long double dot(point a, point b) {
    return std::real(std::conj(a) * b);
}

long double cross(point a, point b) {
    return std::imag(std::conj(a) * b);
}


class segment {
public:
    segment()
        : a(point(0, 0)),
          b(point(0, 0))
    {}
    segment(point a_, point b_)
        : a(a_), b(b_)
    {}

    point a, b;
};

class line {
public:
    line()
        : a(point(0, 0)), b(point(0, 0))
    {}
    line(point a_, point b_)
        : a(a_), b(b_)
    {}
    line(segment s)
        : a(s.a), b(s.b)
    {}

    point a, b;
};


int ccw(point a, point b, point c) {
    b -= a; c -= a;
    if(cross(b, c) > eps)           return 1;  // a -> b -> c : counterclockwise
    if(cross(b, c) < -eps)          return -1; // a -> b -> c : clockwise
    if(dot(b, c) < 0)               return 2;  // c -> a -> b : line
    if(std::norm(b) < std::norm(c)) return -2; // a -> b -> c : line
    return 0;                                  // a -> c -> b : line
}


bool isis_ll(line l, line m) {
    return !eq(cross(l.b - l.a, m.b - m.a), 0);
}

bool isis_ls(line l, segment s) {
    return (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

bool isis_lp(line l, point p) {
    return (std::abs(cross(l.b - p, l.a - p)) < eps);
}

bool isis_sp(segment s, point p) {
    return (std::abs(s.a - p) + std::abs(s.b - p) - std::abs(s.b - s.a) < eps);
}

bool isis_ss(segment s, segment t) {
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0
        && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

point proj(line l, point p) {
    long double t = dot(p - l.a, l.a - l.b) / std::norm(l.a - l.b);
    return l.a + t * (l.a - l.b);
}

long double dist_lp(line l, point p) {
    return std::abs(p - proj(l, p));
}

long double dist_ll(line l, line m) {
    return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}

long double dist_ls(line l, segment s) {
    return isis_ls(l, s) ? 0 : std::min(dist_lp(l, s.a), dist_lp(l, s.b));
}

long double dist_sp(segment s, point p) {
    point r = proj(line(s), p);
    return isis_sp(s, r) ? std::abs(r - p) : std::min(std::abs(s.a - p), std::abs(s.b - p));
}

long double dist_ss(segment s, segment t) {
    if(isis_ss(s, t)) return 0;
    long double d1 = std::min(dist_sp(s, t.a), dist_sp(s, t.b));
    long double d2 = std::min(dist_sp(t, s.a), dist_sp(t, s.b));
    return std::min(d1, d2);
}

// 0 -> on, 1 -> in, 2 -> out
int is_in_polygon(polygon const& poly, point p) {
    int N = poly.size();
    ld sum = 0;
    for(int i=0; i<N; ++i) {
        point p1 = poly[i], p2 = poly[(i+1)%N];
        if(isis_sp(segment(p1, p2), p)) {
            return 0;
        }
        sum += arg((p2 - p) / (p1 - p));
    }
    return abs(sum) < pi / 2 ? 2 : 1;
}

polygon convex_hull(vector<point> ps) {
    sort(ps.begin(), ps.end(), [&](point const& p1, point const& p2) {
        if(real(p1) == real(p2)) {
            return imag(p1) < imag(p2);
        }
        return real(p1) < real(p2);
    });
    const int n = ps.size();
    int k = 0;
    polygon qs(2*n);
    for(int i=0; i<n; ++i) {
        while(k > 1 && ccw(qs[k-2], qs[k-1], ps[i]) <= 0) {
            k--;
        }
        qs[k++] = ps[i];
    }
    for(int i=n-2, t = k; i>=0; --i) {
        while(k > t && ccw(qs[k-2], qs[k-1], ps[i]) <= 0) {
            k--;
        }
        qs[k++] = ps[i];
    }
    qs.resize(k-1);
    return qs;
}

ld dist_pp(polygon const& p1, polygon const& p2) {
    ld res = 1e18;
    const int n = p1.size();
    const int m = p2.size();
    for(int i = 0; i < n; ++i) {
        segment seg1(p1[i], p1[(i + 1) % n]);
        for(int j = 0; j < m; ++j) {
            segment seg2(p2[j], p2[(j + 1) % m]);
            res = min(res, dist_ss(seg1, seg2));
        }
    }
    return res;
}


} // namespace geometry2d

using namespace geometry2d;

int main() {
    int N;
    while(cin >> N, N) {
        vector<polygon> poly(N);
        vector<ld> h(N);
        for(int i = 0; i < N; ++i) {
            int Nv;
            cin >> Nv >> h[i];
            for(int j = 0; j < Nv; ++j) {
                ld x, y;
                cin >> x >> y;
                poly[i].emplace_back(x, y);
            }
        }
        ld theta, phi;
        point p[2];
        cin >> theta >> phi;
        for(int i = 0; i < 2; ++i) {
            ld x, y;
            cin >> x >> y;
            p[i] = point(x, y);
        }

        theta = theta / 180 * pi + pi;
        phi = phi / 180 * pi;
        point vec(cos(theta), sin(theta));
        for(int i = 0; i < N; ++i) {
            point v = vec * h[i] / tan(phi);
            const int m = poly[i].size();
            for(int j = 0; j < m; ++j) {
                poly[i].push_back(poly[i][j] + v);
            }
            poly[i] = convex_hull(poly[i]);
        }

        vector<vector<ld>> d(N+2, vector<ld>(N+2, 1e18));
        for(int i = 0; i < N + 2; ++i) {
            d[i][i] = 0;
        }
        d[N][N+1] = d[N+1][N] = abs(p[0] - p[1]);
        for(int i = 0; i < N; ++i) {
            for(int j = i + 1; j < N; ++j) {
                d[i][j] = d[j][i] = dist_pp(poly[i], poly[j]);
            }
            
            for(int j = 0; j < 2; ++j) {
                ld dist = 1e18;
                if(is_in_polygon(poly[i], p[j]) != 2) {
                    dist = 0;
                } else {
                    const int m = poly[i].size();
                    for(int k = 0; k < m; ++k) {
                        segment seg(poly[i][k], poly[i][(k + 1) % m]);
                        dist = min(dist, dist_sp(seg, p[j]));
                    }
                }
                d[i][N + j] = d[N + j][i] = dist;
            }
        }

        for(int k = 0; k < N + 2; ++k) {
            for(int i = 0; i < N + 2; ++i) {
                for(int j = 0; j < N + 2; ++j) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        cout << fixed << setprecision(10) << d[N+1][N] << endl;
    }
}


Measured memory_bytes: 3828