#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X!=b.X) ? a.X<b.X : a.Y<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
P unit(const P &p){
    return p/abs(p);
}
P rotate(const P &p, double rad){
    return p *P(cos(rad), sin(rad));
}

bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}
double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
double distanceSP(const L &s, const P &p) {
    if(dot(s[1]-s[0], p-s[0]) < EPS) return abs(p-s[0]);
    if(dot(s[0]-s[1], p-s[1]) < EPS) return abs(p-s[1]);
    return distanceLP(s, p);
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

int in_poly(const P &p, const VP &poly){
    int n = poly.size();
    int ret = -1;
    for(int i=0; i<n; i++){
        P a = poly[i]-p;
        P b = poly[(i+1)%n]-p;
        if(a.Y > b.Y) swap(a,b);
        if(intersectSP(L(a,b), P(0,0))) return 0;
        if(a.Y<=0 && b.Y>0 && cross(a,b)<0) ret = -ret;
    }
    return ret;
}

VP convex(VP v){
    VP ret;
    int n = v.size();
    sort(v.begin(), v.end());
    for(int i=0; i<n; i++){
        while((int)ret.size()>1 && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    int t = ret.size();
    for(int i=n-2; i>=0; i--){
        while((int)ret.size()>t && cross(ret.back()-ret[ret.size()-2], v[i]-ret.back()) < EPS){
            ret.pop_back();
        }
        ret.push_back(v[i]);
    }
    if((int)ret.size() > 1) ret.pop_back();
    return ret;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<VP> poly(n);
        vector<double> h(n);
        for(int i=0; i<n; i++){
            int nv;
            cin >> nv >> h[i];
            poly[i].resize(2*nv);
            for(int j=0; j<nv; j++){
                double x,y;
                cin >> x >> y;
                poly[i][j] = P(x, y);
            }
        }

        double theta, phi;
        cin >> theta >> phi;
        P dir = rotate(P(-1, 0), theta/180 *PI) /tan(phi/180 *PI);
        vector<VP> con(n);
        for(int i=0; i<n; i++){
            int nv = poly[i].size()/2;
            for(int j=0; j<nv; j++){
                poly[i][nv +j] = poly[i][j] +h[i]*dir;
            }
            con[i] = convex(poly[i]);
        }
        
        double sx,sy,gx,gy;
        cin >> sx >> sy >> gx >> gy;
        P s(sx, sy), g(gx, gy);
        vector<vector<double> > adj(n+2, vector<double>(n+2, INF));
        for(int i=0; i<n; i++){
            for(int j=i; j<n; j++){
                double dist = INF;
                int ni = con[i].size();
                int nj = con[j].size();
                for(int k=0; k<ni; k++){
                    for(int l=0; l<nj; l++){
                        dist = min(dist, distanceSS(L(con[i][k], con[i][(k+1)%ni]), L(con[j][l], con[j][(l+1)%nj])));
                    }
                }
                adj[i][j] = adj[j][i] = dist;
            }
            double sdist = INF, gdist = INF;
            int ni = con[i].size();
            for(int j=0; j<ni; j++){
                sdist = min(sdist, distanceSP(L(con[i][j], con[i][(j+1)%ni]), s));
                gdist = min(gdist, distanceSP(L(con[i][j], con[i][(j+1)%ni]), g));
            }
            if(in_poly(s, con[i]) >= 0) sdist = 0;
            if(in_poly(g, con[i]) >= 0) gdist = 0;
            adj[n][i] = adj[i][n] = sdist;
            adj[n+1][i] = adj[i][n+1] = gdist;
        }
        adj[n][n+1] = min(adj[n][n+1], abs(s-g));
        adj[n+1][n] = min(adj[n+1][n], abs(s-g));

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


Measured memory_bytes: 3844