#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;
#define X real()
#define Y imag()
#define EPS (1e-10)
#define INF (1e15)

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
  bool cmp_y(const P &a, const P &b){
    return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
  }
}

double dot(P a, P b){
  return a.X * b.X + a.Y * b.Y;
}
double cross(P a, P b){
  return a.X * b.Y - a.Y * b.X;
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if( cross(b,c) > EPS ) return +1;
  if( cross(b,c) < -EPS ) return -1;
  if( dot(b,c) < -EPS ) return +2;
  if( abs(b) + EPS < abs(c) ) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) < 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) < 0) return true;
  return false;
}

P projection(P a, P b){
  //ベクトルaにのベクトルbに対する正射影ベクトル
  return dot(a, b)/abs(b)/abs(b)*b;
}

P line_symmetry(L l, P p){
  //点pと直線lに対して線対称な点
  return p + (l.first - p + projection(p-l.first,l.second-l.first))*2.0;
}

int in_poly(P a, Poly p){
  int n = p.size(), c = 0;
  p.push_back(p[0]);
  for(int i = 0; i < n; ++i){
    P s = p[i]-a, t = p[i+1]-a;
    if(!ccw(s,t,P(0,0))) return 1;//辺上
    if(s.Y > t.Y + EPS) swap(s,t);
    if((s.Y*t.Y < -EPS || (s.Y*t.Y < EPS && t.Y > EPS)) && cross(s,t) < EPS) ++c;
  }
  if(c%2) return 2;//内部
  return 0;//外部
}

double dijkstra(vector< vector<double> > &G){
  int n = G.size();
  vector<double> d(n,INF);
  priority_queue< pair<double,int> > wait;
  wait.push(make_pair(0,0));
  while(!wait.empty()){
    double dist = -wait.top().first;
    int v = wait.top().second;
    wait.pop();
    if(d[v] <= dist) continue;
    d[v] = dist;
    for(int i = 0; i < n; ++i){
      if(dist + G[v][i] < d[i]){
        wait.push(make_pair(-dist - G[v][i],i));
      }
    }
  }
  return d[1];
}

vector< vector<double> > make_graph(P start, P goal, Poly q, Poly p){
  int n = p.size() + q.size() + 2;
  vector< vector<double> > G(n, vector<double>(n,INF));

  Poly S;
  S.push_back(start);
  S.push_back(goal);
  for(int i = 0; i < q.size(); ++i) S.push_back(q[i]);
  for(int i = 0; i < p.size(); ++i) S.push_back(p[i]);
  /*
  for(int i = 0; i < n; ++i)
    cout << S[i] << endl;
  */
  vector<L> E;
  for(int i = 0; i < q.size(); ++i)
    E.push_back(make_pair(q[i],q[(i+1)%q.size()]));
  for(int i = 0; i < p.size(); ++i)
    E.push_back(make_pair(p[i],p[(i+1)%p.size()]));

  for(int i = 0; i < n; ++i){
    for(int j = i; j < n; ++j){
      if(in_poly((S[i]+S[j])/2.0,q) && in_poly((S[i]+S[j])/2.0,p)){
        bool f = true;
        for(int k = 0; k < E.size(); ++k){
          if((ccw(S[i],S[j],E[k].first) == 0 && abs(S[i]-E[k].first) > EPS && abs(S[j]-E[k].first) > EPS) ||
             (ccw(S[i],S[j],E[k].second) == 0 && abs(S[i]-E[k].second) > EPS && abs(S[j]-E[k].second) > EPS)){
            f = false;
            break;
          }
          if(is_cross(L(S[i],S[j]),E[k])){
            f = false;
            break;
          }
        }
        if(f){
          G[i][j] = abs(S[i]-S[j]);
          G[j][i] = G[i][j];
        }
      }
    }
  }
  return G;
}

int main(){
  int N, M;
  while(cin >> N, N){
    double x, y;
    vector<Poly> polys(N);
    for(int i = 0; i < N; ++i){
      cin >> M;
      for(int j = 0; j < M; ++j){
        cin >> x >> y;
        polys[i].push_back(P(x,y));
      }
    }
    cin >> x >> y;
    P start(x,y);
    cin >> x >> y;
    P goal(x,y);
    double x_, y_;
    cin >> x >> y >> x_ >> y_;
    L l(P(x,y),P(x_,y_));
    P start_ = line_symmetry(l,start);;
    Poly p, q;
    bool f = false, g = false;
    for(int i = 0; i < N; ++i){
      if(in_poly(start,polys[i])){
        p = polys[i];
        f = true;
      }
      if(in_poly(start_,polys[i])){
        q = polys[i];
        g = true;
      }
    }
    if(!(f&&g)){
      cout << "impossible" << endl;
      continue;
    }
    for(int i = 0; i < q.size(); ++i){
      q[i] = line_symmetry(l,q[i]);
    }
    vector< vector<double> > G = make_graph(start,goal,q,p);

    /*
    for(int i = 0; i < G.size(); ++i){
      for(int j = 0; j < G.size(); ++j){
        if(G[i][j] >= INF) cout << " INF  | ";
        else printf("%.3f | ",G[i][j]);
      }cout << endl;
    }
    */
    double ans = dijkstra(G);
    if(ans >= INF) cout << "impossible" << endl;
    else printf("%.12f\n",ans);
  }
  return 0;
}



Measured memory_bytes: 3424