#include<bits/stdc++.h>
#include<complex>

using namespace std;

#define rep(i,n) for(int i = 0; i<(n); ++i)
#define reps(i,a,n) for(int i = (a); i<(n); ++i)


#define X real()
#define Y imag()
#define at(i) ((*this)[i])
#define SELF (*this)
enum {TRUE = 1, FALSE = 0, BORDER = -1};
typedef int BOOL;
typedef double R;
const R INF = 1e8;
R EPS = 1e-12;
const R PI = 3.1415926535897932384626;
inline int sig(const R &x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
inline BOOL less(const R &x, const R &y) {return sig(x-y) ? x < y : BORDER;}
typedef complex<R> P;
inline R norm(const P &p){return p.X*p.X+p.Y*p.Y;}
inline R inp(const P& a, const P& b){return (conj(a)*b).X;}
inline R outp(const P& a, const P& b){return (conj(a)*b).Y;}
inline P unit(const P& p){return p/abs(p);}
inline P proj(const P &s, const P &t){return t*inp(s, t)/norm(t);}
inline int ccw(const P &s, const P &t, const P &p, int adv=0){
int res = sig(outp(t-s, p-s));
if(res || !adv) return res;
if(sig(inp(t-s, p-s)) < 0) return -2; // p-s-t
if(sig(inp(s-t, p-t)) < 0) return 2; // s-t-p
return 0; // s-p-t
}
struct L : public vector<P>{ // line
L(const P &p1, const P &p2){this->push_back(p1);this->push_back(p2);}
L(){}
P dir()const {return at(1) - at(0);}
BOOL online(const P &p)const {return !sig(outp(p-at(0), dir()));}
};
struct S : public L{ // segment
S(const P &p1, const P &p2):L(p1, p2){}
S(){}
BOOL online(const P &p)const {
if(!sig(norm(p - at(0))) || !sig(norm(p - at(1)))) return BORDER;
// 座標の二乗とEPS の差が大きすぎないように注意
return !sig(outp(p-at(0), dir())) && inp(p-at(0), dir()) > EPS && inp(p-at(1),
-dir()) > -EPS;
//return !sig(abs(at(0)-p) + abs(at(1) - p) - abs(at(0) - at(1)));
}
};
// 射影と反射 (s を t に)
inline P proj(const P &s, const L &t){return t[0] + proj(s-t[0], t[1]-t[0]);}
inline P reflect(const P &s, const L &t){return (R)2.*proj(s, t) - s;}
inline S reflect(const S &s, const L &t){return S(reflect(s[0], t), reflect(s[1], t
));}
// 交差判定
BOOL intersect(const S &s, const S &t){
const int p = ccw(t[0], t[1], s[0], 1) * ccw(t[0], t[1], s[1], 1);
const int q = ccw(s[0], s[1], t[0], 1) * ccw(s[0], s[1], t[1], 1);
return (p>0||q>0) ? FALSE : (!p||!q) ? BORDER : TRUE;
}
BOOL intersect(const S &s, const L &l){
if(l.online(s[0]) || l.online(s[1])) return BORDER;
return (sig(outp(l.dir(), s[0]-l[0])) * sig(outp(l.dir(), s[1]-l[0])) <= 0);
}
// dist2: 距離の二乗, dist: 距離
R dist2(const L &l, const P &p){return norm(outp(l.dir(), p - l[0])) / norm(l.dir());}
R dist2(const S &s, const P &p){
if(inp(p-s[0], s.dir()) < EPS) return norm(p - s[0]);
if(inp(p-s[1], -s.dir()) < EPS) return norm(p - s[1]);
return dist2((const L &)s, p);
}
R dist2(const S &s, const L &l){
return intersect(s, l) ? .0 : min(dist2(l, s[0]), dist2(l, s[1]));
}
R dist2(const S &s, const S &t){
return intersect(s, t) ? .0 : min(min(dist2(s, t[0]), dist2(t, s[0])),
min(dist2(s, t[1]), dist2(t, s[1])));
}
template<class S, class T> R dist(const S& s, const T& t){return sqrtl(dist2(s, t));}
inline P crosspoint(const L &l, const L &m){
R A = outp(l.dir(), m.dir()), B = outp(l.dir(), l[1] - m[0]);
if(!sig(abs(A)) && !sig(abs(B))) return m[0]; // same line
if(abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
return m[0] + B / A * (m[1] - m[0]);
}



using pi = pair<int, R>;

int H[102];
vector<P> XY[102];
int beg[102];

vector<S> pt[102];
R D[128][128];


int main(){
    int n;
    while(cin >> n){
        if(n == 0)return 0;
        int su = 0;
        rep(i, n){
            int v;
            cin >> v >> H[i];
            XY[i].clear();
            rep(j, v){
                int x,y;
                cin >> x >> y;
                XY[i].push_back(P(x,y));
            }
            su += v*2;
        }
        rep(i,128)rep(j,128) D[i][j] = (i==j ? 0.0 : INF);


        int sita, phi;
        cin >> sita >> phi;
        R SITA = (R)sita*3.14159265358979323 /180;
        R PHI  =  (R)phi*3.14159265358979323 /180;
        P S, T;
        {
            int x,y;
            cin >> x >> y;
            S = P(x,y);
            cin >> x >> y;
            T = P(x,y);
        }
        rep(i, n){
            pt[i].clear();
            int v = XY[i].size();

            R r = H[i] / tan(PHI);
            //P d = -P(r*cos(SITA), r*sin(SITA));
            P d = -polar(r, SITA);
            rep(j, v){
                pt[i].emplace_back(XY[i][j], XY[i][(j+1)%v]);
            }
            rep(j, v){
                pt[i].emplace_back(XY[i][j] + d, XY[i][(j+1)%v] + d);
            }
            rep(j, v){
                pt[i].emplace_back(XY[i][j], XY[i][j] + d);
            }
            
            rep(a,v*2) reps(b,a+1, v*2) reps(c, b+1, v*2){
                int A = ccw(pt[i][a][0], pt[i][b][0], S);
                int B = ccw(pt[i][b][0], pt[i][c][0], S);
                int C = ccw(pt[i][c][0], pt[i][a][0], S);
                if(A != 0 && A == B && B == C) D[n][i] = D[i][n] = 0;
            }
            rep(a,v*2) reps(b,a+1, v*2) reps(c, b+1, v*2){
                int A = ccw(pt[i][a][0], pt[i][b][0], T);
                int B = ccw(pt[i][b][0], pt[i][c][0], T);
                int C = ccw(pt[i][c][0], pt[i][a][0], T);
                if(A != 0 && A == B && B == C) D[n+1][i] = D[i+1][n] = 0;
            }
            
            for(auto&S:pt[i]){
                //cout << "line(" << S[0].X<<", "<< S[0].Y<<", "<< S[1].X<<", "<< S[1].Y<<")"<<endl;
            }
        }
        //cout << "circle(" << S.X << ", " << S.Y << ", 1)" << endl;
        //cout << "circle(" << T.X << ", " << T.Y << ", 1)" << endl;



        rep(i, n)reps(j, i+1, n){
            R d = INF;
            for(auto&A : pt[i]) for(auto&B : pt[j]) {
                d = min(d, dist2(A,B));
            }
            D[i][j] = D[j][i] = sqrt(d);
        }
        rep(i, n){
            R d = D[n][i];
            for(auto&A : pt[i]){
                d = min(d, dist2(A, S));
            }
            D[i][n] = D[n][i] = sqrt(d);
        }
        rep(i, n){
            R d = D[n+1][i];
            for(auto&A : pt[i]){
                d = min(d, dist2(A, T));
            }
            D[i][n+1] = D[n+1][i] = sqrt(d);
        }
        D[n][n+1] = D[n+1][n] = abs(S-T);
        /*
        rep(i, n+2){
            rep(j, n+2){
                printf("%9.5lf", (double)D[i][j]);
            }
            puts("");
        }
        */
        rep(k, n+2)rep(i, n+2) rep(j, n+2){
            D[i][j] = D[j][i] = min(D[i][j] , D[i][k] + D[k][j]);
        }
        printf("%.9lf", (double)D[n][n+1]);
        puts("");

    }
}
/*
 */





Measured memory_bytes: 4048