#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

namespace geo{
    using real_num = double;
    constexpr real_num eps = 1e-9;
    constexpr real_num PI = 3.14159265358979323846264338327950;
    
    inline int sgn(real_num x){
        if(x < -eps) return -1;
        if(x > eps) return 1;
        return 0;
    }

    inline bool eq(real_num x, real_num y){
        return sgn(x - y) == 0;
    }

    inline bool ge(real_num x, real_num y){
        return sgn(x - y) == 1;
    }

    inline bool le(real_num x, real_num y){
        return sgn(x - y) == -1;
    }

    inline bool geq(real_num x, real_num y){
        return sgn(x - y) >= 0;
    }

    inline bool leq(real_num x, real_num y){
        return sgn(x - y) <= 0;
    }

    struct Point{
        real_num x, y;
        Point(real_num x = 0, real_num y = 0): x(x), y(y){}

        Point operator+(const Point &p){
            return {x + p.x, y + p.y};
        }

        Point operator-(const Point &p){
            return {x - p.x, y - p.y};
        }

        Point operator*(const real_num k){
            return {x * k, y * k};
        }

        Point operator/(const real_num k){
            return {x / k, y / k};
        }

        real_num operator*(const Point &p){
            return x * p.x + y * p.y;
        }

        real_num operator^(const Point &p){
            return x * p.y - y * p.x;
        }

        bool operator==(const Point &p){
            return eq(x, p.x) && eq(y, p.y);
        }

        bool operator<(const Point &p) const{
            if(eq(x, p.x)) return le(y, p.y);
            return le(x, p.x);
        }
    };

    using Vec = Point;
    using Points = vector<Point>;
    using Polygon = vector<Point>;

    real_num norm(Point p){
        return p.x * p.x + p.y * p.y;
    }

    real_num abs(Point p){
        return sqrt(norm(p));
    }

    Point rot(Point p, real_num t){
        return {p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t)};
    }

    constexpr int CCW_COUNTER_CLOCKWISE = 1;
    constexpr int CCW_CLOCKWISE = -1;
    constexpr int CCW_ONLINE_BACK = -2;
    constexpr int CCW_ONLINE_FRONT = 2;
    constexpr int CCW_ON_SEGMENT = 0;

    inline int ccw(Point a, Point b, Point c){
        Vec v = b - a, w = c - a;
        if(ge(v ^ w, 0)) return CCW_COUNTER_CLOCKWISE;
        if(le(v ^ w, 0)) return CCW_CLOCKWISE;
        if(le(v * w, 0)) return CCW_ONLINE_BACK;
        if(le((a - b) * (c - b), 0)) return CCW_ONLINE_FRONT;
        return CCW_ON_SEGMENT;
    }

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

    real_num distance_lp(Point a, Vec v, Point p){
        return abs(v ^ (p-a) / abs(v));
    }

    real_num distance_sp(Point a, Point b, Point p){
        if(le((b - a) * (p - a), 0)) return abs(p - a);
        if(le((a - b) * (p - b), 0)) return abs(p - b);
        return distance_lp(a, b - a, p);
    }

    real_num distance_ss(Point a, Point b, Point c, Point d){
        if(has_intersection_ss(a, b, c, d)) return 0;
        return min({distance_sp(a, b, c), distance_sp(a, b, d), distance_sp(c, d, a), distance_sp(c, d, b)});
    }

    int point_in_polygon(Point a, Polygon &p){
        int n = p.size(), wn = 0;
        rep(i, n){
            int j = (i + 1) % n;
            if(eq(distance_sp(p[i], p[j], a), 0)) return 1;
            else if(leq(p[i].y, a.y) && le(a.y, p[j].y)){
                wn += (ccw(a, p[i], p[j]) == CCW_COUNTER_CLOCKWISE);
            }
            else if(leq(p[j].y, a.y) && le(a.y, p[i].y)){
                wn -= (ccw(a, p[i], p[j]) == CCW_CLOCKWISE);
            }
        }
        return wn == 0 ? 0 : 2;
    }

    Polygon convex_hull(Points p){
        int n = p.size();
        sort(p.begin(), p.end());
        Polygon ch(2 * n);
        int k = 0;
        rep(i, n){
            while(k > 1 && le((ch[k - 1] - ch[k - 2]) ^ (p[i] - ch[k - 1]), 0)) --k;
            ch[k++] = p[i];
        }
        for(int i = n - 2, t = k; i >= 0; --i){
            while(k > t && le((ch[k - 1] - ch[k - 2]) ^ (p[i] - ch[k - 1]), 0)) --k;
            ch[k++] = p[i];
        }
        ch.resize(k - 1);
        return ch;
    }
}

using namespace geo;
int n;

void solve(){
    real_num h[n];
    Points p[n];
    rep(i, n){
        int K;
        scanf("%d%lf", &K, &h[i]);
        p[i].resize(K * 2);
        rep(j, K) scanf("%lf%lf", &p[i][j].x, &p[i][j].y);
    }
    real_num theta, phi;
    scanf("%lf%lf", &theta, &phi);
    rep(i, n){
        rep(j, p[i].size() / 2){
            Point q = p[i][j] + rot({-h[i] / tan(phi * PI / 180), 0}, theta * PI / 180);
            p[i][j + p[i].size() / 2] = q;
        }
        p[i] = convex_hull(p[i]);
    }

    real_num dist[n + 2][n + 2];
    rep(i, n){
        dist[i][i] = 0;
        For(j, i + 1, n){
            real_num tmp = INF;
            rep(k, p[i].size())rep(l, p[j].size()){
                chmin(tmp, distance_ss(p[i][k], p[i][(k + 1) % p[i].size()], p[j][l], p[j][(l + 1) % p[j].size()]));
            }
            dist[i][j] = dist[j][i] = tmp;
        }
    }
    Point sp, tp;
    scanf("%lf%lf%lf%lf", &sp.x, &sp.y, &tp.x, &tp.y);
    dist[n][n] = dist[n + 1][n + 1] = 0;
    rep(i, n){
        if(point_in_polygon(sp, p[i]) >= 1){
            dist[i][n] = dist[n][i] = 0;
            continue;
        }
        real_num tmp = INF;
        rep(j, p[i].size()){
            chmin(tmp, distance_sp(p[i][j], p[i][(j + 1) % p[i].size()], sp));
        }
        dist[i][n] = dist[n][i] = tmp;
    }
    rep(i, n){
        if(point_in_polygon(tp, p[i]) >= 1){
            dist[i][n + 1] = dist[n + 1][i] = 0;
            continue;
        }
        real_num tmp = INF;
        rep(j, p[i].size()){
            chmin(tmp, distance_sp(p[i][j], p[i][(j + 1) % p[i].size()], tp));
        }
        dist[i][n + 1] = dist[n + 1][i] = tmp;
    }
    dist[n][n + 1] = dist[n + 1][n] = abs(sp - tp);

    rep(k, n + 2)rep(i, n + 2)rep(j, n + 2){
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
    }
    printf("%.10lf\n", dist[n][n + 1]);
}

int main(){
    while(scanf("%d", &n) && n){
        solve();
    }
}


Measured memory_bytes: 3776