#include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

using ld=long double;
using cm=complex<ld>;
#define x real()
#define y imag()
const ld eps=1e-8;
const ld PI=acos(ld(-1));
int sgn(ld a){return a<-eps?-1:(a>eps?1:0);}
ld dot(cm a,cm b){return a.x*b.x+a.y*b.y;}
ld crs(cm a,cm b){return a.x*b.y-a.y*b.x;}
ld crs(cm a,cm b,cm c){return crs(b-a,c-a);}
int ccw(cm a,cm b){return sgn(crs(a,b));}
int ccw(cm a,cm b,cm c){return ccw(b-a,c-a);}
auto cmcmp=[](cm a,cm b){
	int s=sgn(a.x-b.x);
	if(s)return s<0;
	else return sgn(a.y-b.y)<0;
};
bool cmeq(cm a,cm b){
	return sgn(a.x-b.x)==0&&sgn(a.y-b.y)==0;
};
//(-pi,0](0,pi]
int argtype(cm a){
	if(sgn(a.y)==0)return a.x<0?1:0;
	return a.y<0?0:1;
}
int argcmp(cm a,cm b){
	int at=argtype(a),bt=argtype(b);
	if(at!=bt)return at<bt?-1:1;
	return -ccw(a,b);
};
//(-2)[a,-1](0)[b,1](2)
int bet(cm a,cm b,cm c){
	cm d=b-a;
	ld e=dot(d,c-a);
	if(sgn(e)<=0)return sgn(e)-1;
	return sgn(e-norm(d))+1;
}

using ln=pair<cm,cm>;
cm dir(ln a){return a.b-a.a;}
cm eval(ln a,ld b){return a.a+dir(a)*b;}
int bet(ln a,cm b){return bet(a.a,a.b,b);}
int ccw(ln a,cm b){return ccw(a.a,a.b,b);}
cm proj(ln a,cm b){
	cm c=dir(a);
	return a.a+c*dot(c,b-a.a)/norm(c);
}
cm refl(ln a,cm b){
	return ld(2)*proj(a,b)-b;
}
//AOJ0153
ld dsp(ln a,cm b){
	cm c=proj(a,b);
	if(abs(bet(a.a,a.b,c))<=1)return abs(b-c);
	return min(abs(b-a.a),abs(b-a.b));
}
//AOJ1157
//0-no,1-yes(endpoint),2-yes(innner),3-overelap
int iss(ln a,ln b){
	int c1=ccw(a.a,a.b,b.a),c2=ccw(a.a,a.b,b.b);
	int d1=ccw(b.a,b.b,a.a),d2=ccw(b.a,b.b,a.b);
	if(c1||c2||d1||d2)return 1-max(c1*c2,d1*d2);
	int f=bet(a.a,a.b,b.a),g=bet(a.a,a.b,b.b);
	if(max(f,g)==-2||min(f,g)==2)return 0;
	return 3;
}
//AOJ1033
cm cll(ln a,ln b){
	return eval(a,crs(b.a,b.b,a.a)/crs(dir(a),dir(b)));
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	while(1){
		int n;cin>>n;
		if(n==0)break;
		vc<ln> ms;
		rep(i,n){
			ld a,b,c,d;cin>>a>>b>>c>>d;
			ms.eb(cm(a,b),cm(c,d));
		}
		cm s,t;
		{
			ld a,b;cin>>a>>b;
			s=cm(a,b);
		}
		{
			ld a,b;cin>>a>>b;
			t=cm(a,b);
		}
		auto chk=[&](ln a){
			for(auto l:ms)
				if(iss(l,a)==2)return false;
			return true;
		};
		double ans=1e9;
		auto upd=[&](vi idx){
			vc<ln> cur=ms,r;
			cm g=t;
			for(auto i:idx){
				r.pb(cur[i]);
				ln w=cur[i];
				for(auto&l:cur)
					l=ln(refl(w,l.a),refl(w,l.b));
				g=refl(w,g);
			}
			vc<cm> ps{s};
			for(auto l:r){
				if(iss(ln(s,g),l)==2)
					ps.pb(cll(ln(s,g),l));
				else
					return;
			}
			ps.pb(g);
			dmp(idx);
			dmp(ps);
			rep(i,ps.size()-2)
				if(bet(ps[i],ps[i+2],ps[i+1]))
					return;
			rep(i,r.size())
				rng(j,ps.size()-1-i,ps.size())
					ps[j]=refl(r[r.size()-1-i],ps[j]);
			dmp(idx);
			rep(i,ps.size()-1)
				if(!chk(ln(ps[i],ps[i+1])))
					return;
			dmp(idx);
			chmin(ans,abs(g-s));
		};
		function<void(vi)>dfs=[&](vi idx){
			upd(idx);
			if(idx.size()<6){
				int last=-1;
				if(idx.size())last=idx.back();
				rep(i,n)if(i!=last){
					vi nx=idx;
					nx.pb(i);
					dfs(nx);
				}
			}
		};
		dfs({});
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3308