#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;


// 以下 幾何部分
template<class T> bool operator==(T a, T b){return abs(a-b)< eps;}
template<class T> bool operator< (T a, T b){return a < b-eps;}
template<class T> bool operator<=(T a, T b){return a < b+eps;}
template<class T> int sig(T r) {return (r==0||r==-0) ? 0 : r > 0 ? 1 : -1;}
#define X real()
#define Y imag()
#define mp make_pair

typedef bool B;
typedef long double D;
typedef complex<D> P;
typedef vector<P> VP;
typedef pair <P,P> L;
typedef vector<L> VL;
typedef struct {P c;D r;} C;
typedef struct {P c;D a,b;} E; // 楕円も追加予定
typedef vector <P> Pol;

// ソートのキー
inline B cmp_x(const P &a,const P &b){ return (abs(a.X-b.X)<eps ) ?  a.Y<b.Y : a.X<b.X;}  // base x
inline B cmp_y(const P &a,const P &b){ return (abs(a.Y-b.Y)<eps ) ?  a.X<b.X : a.Y<b.Y;}  // base y
inline B cmp_a(const P &a,const P &b){ return (abs(arg(a)-arg(b))<eps ) ?  norm(a) < norm(b) : arg(a)<arg(b);} // base arg


// 基本操作
// verify
D ip(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D ep(P a, P b) {return a.X * b.Y - a.Y * b.X;}
D sr(D a) {return sqrt(max(a, (D)0));}
P vec(L l){return l.second-l.first;}


// 点
D toRagian(D degree){ return degree*pi/180.0;}
D ang (P p){return arg(p);}
D ang (P base, P a, P b) {return arg( (b - base) / (a - base) );} // base 中心
P rot (P base, P a, D theta){return base+polar( abs(a-base), arg(a-base)+theta );}

P proj(P b,P p){ return b*ip(b,p)/norm(b);} 
P proj(L l,P p){ return l.first+proj(vec(l),p-l.first);}
P refl(L l,P p){ return proj(l,p)*D(2.0)-p; }
// ccw 
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, MID = 16, ON=FRONT|BACK|MID };

inline int ccw(P base, P a, P b) {              //点aと点bが与えられた問いに
  a -= base; b -= base;
  if (ep(a, b) > eps)   	 return LEFT;    // counter clockwise
  if (ep(a, b) < -eps)      return RIGHT;   // clockwise
  if (ip(a, b) < 0)      return BACK;    // b--base--a on line
  if (norm(a) < norm(b)) return FRONT;   // base--a--b on line
  						 return MID;      // base--b--a on line  aとbの線分判定はこれ
}

// 線分 直線
	// 点と直線の距離
	// 点と線分の距離
	// 直線と直線の距離
	

B iver(L a, L b) {return ip(vec(a),vec(b) )== 0.0;}
B ipar(L a, L b) {return ep(vec(a),vec(b) )== 0.0;}


// 交点
P pLL(L a,L b){ return a.first+vec(a)*ep(vec(b),b.first-a.first)/ep(vec(b), vec(a));}

// 点と直線と線分関連の交差判定

B iLL(L l1,L l2){ return !ipar(l1,l2);}
B eqL(L a, L b) {return !iLL(a, b) && ep(vec(a), b.first - a.first)==0;}
B iLS(L a, L b)  {return sig(ep(vec(a), b.first - a.first)) * sig(ep(vec(a), b.second - a.first)) <= 0;}
B iLSs(L a, L b) {return sig(ep(vec(a), b.first - a.first)) * sig(ep(vec(a), b.second - a.first)) <  0;}
B iSS(L a, L b) {
	int cwa = ccw(a.first,a.second, b.first) | ccw(a.first,a.second, b.second);
	int cwb = ccw(b.first,b.second, a.first) | ccw(b.first,b.second, a.second);
	return ((cwa | cwb) & MID) || ((cwa & cwb) == (LEFT | RIGHT));
}
B iSSs(L a, L b) {
	int cwa = ccw(a.first,a.second, b.first) | ccw(a.first,a.second, b.second);
	int cwb = ccw(b.first,b.second, a.first) | ccw(b.first,b.second, a.second);
	return (cwa & cwb) == (LEFT | RIGHT);
}

// 点と直線と線分関連の距離

D dLP(L l,P p){ return abs( ep(vec(l),p-l.first) )/abs(vec(l));}
D dSP(L s,P p){
	if (sig( ip( vec(s), p - s.first)) <= 0) return abs(p - s.first);
	if (sig( ip(-vec(s), p - s.second)) <= 0) return abs(p - s.second);
	return dLP(s,p);
}
D dLL(L a,L b){ return iLL(a,b) ? 0 : dLP(a,b.first);}
D dLS(L a,L b){ return iLS(a,b) ? 0 : min(dLP(a, b.first), dLP(a, b.second));}
D dSS(L a,L b){ return iSS(a,b) ? 0 : min( min(dSP(a,b.first),dSP(a,b.second)),min(dSP(b,a.first),dSP(b,a.second)));}


// 円
// Verify AOJ 1183

enum RCC{A_IN_B=1,B_IN_A=2,A_ON_B=4,B_ON_A=8,ISC=16,ON_OUT=32,OUT=64,SAME=12,ONS=48 };


int rCC(C a,C b){
	D d=abs(a.c-b.c);
	int res=0;
	if(a.r+b.r< d) res|=OUT;
	if(a.r+b.r==d) res|=ON_OUT;
	if(abs(a.r-b.r) < d && d < a.r+b.r) res|=ISC;
	if(d==b.r-a.r) res|=A_ON_B;
	if(d< b.r-a.r) res|=A_IN_B;
	if(d==a.r-b.r) res|=B_ON_A;
	if(d< a.r-b.r) res|=B_IN_A;
	return res;
}

//2つの円の交点
// Verify AOJ 1183

VP pCC(C a,C b){
	VP res;
	int rel=rCC(a,b);
	if(rel==SAME){   // Same
		res.pb(a.c+P(a.r,0));
		res.pb(a.c+P(-a.r,0));
		res.pb(a.c+P(0,a.r));
		res.pb(a.c+P(0,-a.r));
	}else if(rel==ISC){         // 2points
		D d = abs(b.c - a.c);
		D x = (d * d + a.r * a.r - b.r * b.r) / (2 * d);
		P e = (b.c - a.c) / abs(b.c - a.c), w = e * P(0, 1) * sqrt(max(a.r * a.r - x * x, (D)0));
		res.pb(a.c + e * x - w);
		res.pb(a.c + e * x + w);	
	}else if(rel&ONS){ // 1points
		D d = abs(b.c - a.c);
 		D x = (d * d + a.r * a.r - b.r * b.r) / (2 * d);
 		P e = (b.c - a.c) / abs(b.c - a.c);
  		res.pb(a.c + e * x);
	}
	return res;
}

// 円の接線
// Verify AOJ 2001

L tanC(C c,D t){
	P p=c.c+polar(c.r,t);
	P d=polar(c.r,t)*P(0,1);
	return L(p-d,p+d);
}


// 円の共通接線
// Verify AOJ 2001

VL common_tan(C a,C b){
	VL res;
	D d=ang(b.c-a.c);
	D i=acos((a.r+b.r)/abs(b.c-a.c));
	D o=acos((a.r-b.r)/abs(b.c-a.c));
	int r=rCC(a,b);

	if(r==OUT){		//共通内接線
		res.pb(tanC(a,d+i));
		res.pb(tanC(a,d-i));
	}

	if(r>=ISC){		// 共通外接線
		res.pb(tanC(a,d+o));
		res.pb(tanC(a,d-o));
	}

	if(r&ONS)		//接点を共有する接線
		res.pb(tanC(a,d));

	if(r==SAME){
		rep(i,5)
			res.pb(tanC(a,i));
	}
	return res;
}


// 楕円

// 多角形


//verify AOJ CGL_3-C
int in_polygon(Pol pol,P p){
    int n=pol.size();
    int res=0;
    rep(i,n){
        if(ccw(pol[i],pol[(i+1)%n],p)==MID)
            return 1;
        if ((pol[i].Y <= p.Y) && (pol[(i+1)%n].Y>p.Y)){
            D vt=(p.Y-pol[i].Y)/(pol[(i+1)%n].Y-pol[i].Y);
            D dx=pol[(i+1)%n].X-pol[i].X;
            if(p.X < pol[i].X + vt*dx)
                    res++;
        }else if ((pol[i].Y>p.Y)&&(pol[(i+1)%n].Y<=p.Y)){
            D vt=(p.Y - pol[i].Y)/(pol[(i+1)%n].Y-pol[i].Y);
            D dx=pol[(i+1)%n].X-pol[i].X;
            if(p.X <pol[i].X+vt*dx)
                res--;
        }
    }
    return res?2:0;
}


bool in_polygon(Pol pol,L l){
	VP check;
	int n=pol.size();

	rep(i,n){
		L tar=L(pol[i],pol[(i+1)%n]);
		if(iSS(l,tar))
			check.pb(pLL(l,tar));
	}
	check.pb(l.first);
	check.pb(l.second);
	sort(check.begin(),check.end(),cmp_x);
	n=check.size();
	bool res=true;
	rep(i,n-1){
		P m=(check[i]+check[i+1])/P(2.0,0.0);
		if(!in_polygon(pol,m))
			res=false;
	}
	return res;
}

struct node {D to,cost; };

typedef vector< vector<node> > G;

inline void add_edge(G& g,int from,int to,D cost=1){
	node in; in.to=to; in.cost=cost;
	g[from].pb(in);
}

inline void add_both_edge(G& g,int from,int to,D cost=1){	
	add_edge(g,from,to,cost);
	add_edge(g,to,from,cost);
}


struct state{ 
	int from,to;
	D cost;
	bool operator <(state a)const{ return cost < a.cost; }
	bool operator >(state a)const{ return cost > a.cost; } 
};


inline void dijkstra(const G& g,const int s, vector<D>& dist /*, vi& prev*/){
	
	int v=g.size();
	dist.assign(v,inf);
	//prev.assign(v,-1);

	state init;
	init.from=-1;init.to=s;init.cost=0;
	priority_queue < state,vector<state>, greater<state> > q;
	q.push(init);
	dist[s]=0;
	while(!q.empty()){
		state cur=q.top(); q.pop();

		if(dist[cur.to] < cur.cost) 
			continue;

		rep(i,g[cur.to].size()){
			state next;
			next.from=cur.to;
			next.to=g[cur.to][i].to;

			if(dist[next.to] > dist[next.from]+g[cur.to][i].cost){
				dist[next.to]=dist[next.from]+g[cur.to][i].cost;
				next.cost=dist[next.to];
				//prev[next.to]=next.from;
				q.push(next);
			}
		}
	}
	return ;
}

int n,m;

int main(void){
	while(cin >>n,n){
		Pol b[110];
		Pol o,r;
		P s,g;
		L l;

		rep(i,n){
			cin >> m;
			rep(j,m){
				P cur;
				cin >> cur.X >> cur.Y;
				b[i].pb(cur);
			}
		}

		cin >> s.X >> s.Y >> g.X >> g.Y;
		cin >> l.first.X >> l.first.Y >> l.second.X >> l.second.Y;
		int dir=ccw(l.first,l.second,s);
		int sg=-1;
		rep(i,n){
			if(in_polygon(b[i],s)&&in_polygon(b[i],g)){
				sg=i;
				break;
			}
		}

		rep(i,b[sg].size())
			o.pb(refl(l,b[sg][i]));

		s=refl(l,s);
		g=refl(l,g);
		sg=-1;

		rep(i,n){
			if(in_polygon(b[i],s)&&in_polygon(b[i],g)){
				sg=i;
				r=b[i];
				break;
			}
		}
		
		if(sg==-1){
			cout << "impossible" << endl;
			continue;
		}

		VP vertexs;
		rep(i,o.size())
			vertexs.pb(o[i]);
		rep(i,r.size())
			vertexs.pb(r[i]);

		vertexs.pb(s);
		vertexs.pb(g);
		
		int total=vertexs.size();
		G graph(total);
		rep(i,total)rep(j,total){
			if(i>=j) continue;
			L tar=L(vertexs[i],vertexs[j]);
			
			if(in_polygon(o,tar)&&in_polygon(r,tar))
				add_both_edge(graph,i,j,abs(vec(tar)));
		}
		vector<D> dist;
		dijkstra(graph,total-2,dist);

		cout.precision(9);
		if(dist[total-1]!=inf)
			cout << fixed << dist[total-1] << endl;
		else
			cout << "impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 1444