#include<iostream>
#include<cmath>
#include<complex>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define NEXT(i,n) ((i+1)%(n))
  
typedef long long ll;
typedef complex<double> P;

typedef pair<P,P> Mirror;

const double eps = 1e-10;

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

double dot(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}

P symmetric_point(P o,P p,P q){
  P N=p-o,L=q-o;
  double t = abs(L);
  N/=abs(N);
  L/=abs(L);
  double prepL = dot(N,L);//theta element of vector L against N (|L|=|N|=1
  double d=2*prepL;
  P r(d*N - L);//R vector symmetric point of L
  return o+t*r;
}

bool is_intersected_ls(P a1,P a2,P b1,P b2){
  if (cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1)< eps &&
      cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<eps )return true;
  return false;
}

P intersection_ls(P a1,P a2,P b1,P b2){
  P b = b2-b1;
  double d1 = abs(cross(b,a1-b1));
  double d2 = abs(cross(b,a2-b1));
  double t  = d1/(d1+d2);
  return a1+(a2-a1)*t;
}

bool check_hit_mirror(P src,P dst,int hitnum,int *hit,
		      int n,Mirror data[6][5]){
  /*
  cout << "hit information " << endl;
  cout << "hitnum " << hitnum << endl;
  rep(i,hitnum+1){
    if (i != hitnum)cout << "hit " << hit[i] << endl;
    else cout << "current mirror" << endl;
    rep(j,n){
      cout << "mirror " << data[i][j].first <<data[i][j].second<<endl;
    }
  }
  cout << "src" << src <<" dst" << dst<<endl;
  cout <<"hit information end" << endl <<endl;
  */
  

  rep(i,hitnum+1){
    int index = -1;
    double mindist=1e100;
    P tmpp;
    rep(j,n){
      if (i != 0 && j == hit[i-1])continue;
      if (!is_intersected_ls(src,dst,
			     data[i][j].first,data[i][j].second))continue;
      P tmp = intersection_ls(src,dst,data[i][j].first,data[i][j].second);
      double tmpdist=abs(src-tmp);
      if (tmpdist < mindist){
	mindist=tmpdist;
	index = j;
	tmpp = tmp;
      }
    }
    //cout << i << " " << hit[i] << " " << index <<  endl;
    if (i != hitnum && (index == -1 || index != hit[i]))return false;
    else if (i == hitnum && index != -1)return false;
    src=tmpp;
  }
  //  cout <<"good" << endl;
  return true;
}


double ans;

void solve(P src,P dst,int hitnum,int *hit,
	   int n,Mirror data[6][5],int prev){
  if (check_hit_mirror(src,dst,hitnum,hit,n,data))ans=min(ans,abs(src-dst));
  if (hitnum == 6)return;
  rep(i,n){
    if (i == prev)continue;
    P nextdst=symmetric_point(data[hitnum][i].first,data[hitnum][i].second,
			      dst);
    rep(j,n){
      if (i == j){
	data[hitnum+1][j]=data[hitnum][j];
      }else {
	data[hitnum+1][j].first=
	  symmetric_point(data[hitnum][i].first,data[hitnum][i].second,
			  data[hitnum][j].first);
	data[hitnum+1][j].second=
	  symmetric_point(data[hitnum][i].first,data[hitnum][i].second,
			  data[hitnum][j].second);
      }
    }
    hit[hitnum]=i;
    solve(src,nextdst,hitnum+1,hit,n,data,i);
  }
}


main(){
  int n;
  Mirror data[7][5];
  int hit[6];
  while(cin>>n && n){
    P src,dst;
    ans=1e100;
    rep(i,n){
      cin>>data[0][i].first.real()>>data[0][i].first.imag()
	 >>data[0][i].second.real()>>data[0][i].second.imag();
    }

    cin>>dst.real()>>dst.imag();
    cin>>src.real()>>src.imag();

    solve(src,dst,0,hit,n,data,-1);
    printf("%4lf\n",ans);
  }
}

Measured memory_bytes: 1000