// Original C++ solution (slower):
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define fs first

#define sc second

#define pb push_back

#define sz size()



using namespace std;

typedef long double D;

typedef complex<D> P;

typedef pair<P,P> L;



const D EPS = 1e-10;

const D PI = acos(-1);



//for vector

inline pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}

inline D dot(P x, P y){return real(conj(x)*y);}

inline D cross(P x, P y){return imag(conj(x)*y);}



//rotate a point counter-clockwise on the origin

inline P rotate(P v, D s){

  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );

}



//for line(segment)

int ccw(P a,P b,P c){

  b -= a;c -= a;

  if (cross(b,c)>EPS) return 1;   //counter clockwise

  if (cross(b,c)<-EPS) return -1; //clockwise

  if (dot(b, c)<-EPS) return 2;   //c--a--b on line

  if (abs(b)<abs(c)) return -2;   //a--b--c on line

  return 0;                       //on segment

}



inline bool para(L a,L b){return abs(cross(a.fs-a.sc,b.fs-b.sc))<EPS;}



inline P line_cp(L a,L b){

  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);

}



inline bool is_cp(L a,L b){

  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)

    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;

  return false;

}



inline P symmetry_line(L l, P p){

  if(abs(ccw(l.fs,l.sc,p)) != 1)return p;

  P nv = norm(l.fs-l.sc).fs;

  P cp = line_cp(l, L(p,p+nv));

  return cp + rotate(p-cp, PI);

}



struct state{

  P goal;

  vector<L> mirrors;

  state(P p, vector<L> m):goal(p),mirrors(m){}



  state symmetry(int x){

    vector<L> sym(mirrors.sz);

    rep(i,mirrors.sz){

      if(i == x)sym[i] = mirrors[i];

      else sym[i] = L(symmetry_line(mirrors[x],mirrors[i].fs),

		      symmetry_line(mirrors[x],mirrors[i].sc));

    }

    return state(symmetry_line(mirrors[x],goal), sym);

  }

};



const int max_depth = 6;

int n;

D tx,ty,lx,ly;



D rec(int depth, vector<int> &order, vector<state> &mir){

  if(depth == max_depth)return 1e8;

  

  D res = 1e8;



  bool f = true;

  P start = P(lx,ly);

  L route = L(start, mir.back().goal);

  rep(i,depth+1){

    state cur = mir[i];

    int axis = i==depth?-1:order[i], prev = !i?-1:order[i-1];

    if(axis>=0 && !is_cp(route, cur.mirrors[axis])){

      f = false; break;

    }



    P cp = axis>=0?line_cp(route, cur.mirrors[axis]):mir.back().goal;

    L seg = L(start, cp);

    rep(j,n){

      if(axis!=j && prev!=j && is_cp(seg, cur.mirrors[j])){

	f = false; break;

      }

    }

    if(!f)break;

    start = cp; route.fs = start;

  }

  if(f)res = abs(P(lx,ly) - mir.back().goal);



  rep(i,n){

    if(depth && order[depth-1] == i)continue;

    order.pb(i);

    mir.pb(mir.back().symmetry(i));



    res = min(res, rec(depth+1, order, mir) );



    mir.pop_back();

    order.pop_back();

  }



  return res;

}



int main(){

  while(cin >> n, n){

    vector<L> vl(n);

    rep(i,n){

      D px, py, qx, qy;

      cin >> px >> py >> qx >> qy;

      vl[i] = L(P(px,py), P(qx,qy));

    }

    cin >> tx >> ty >> lx >> ly;

    

    vector<state> vs;

    vs.push_back( state(P(tx,ty), vl) );

    vector<int> vi;

    D ans = rec(0, vi, vs);

    cout << fixed << setprecision(4) << ans << endl;

  }

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define fs first

#define sc second

#define pb push_back

#define sz size()



using namespace std;

typedef double D;

typedef complex<D> P;

typedef pair<P,P> L;



const D EPS = 1e-8;

const D PI = acos(-1);



inline pair<P,P> norm(const P &p){return make_pair(p*P(0,1),p*P(0,-1));}

inline D dot(const P &x, const P &y){return real(conj(x)*y);}

inline D cross(const P &x, const P &y){return imag(conj(x)*y);}



int ccw(const 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)<abs(c)) return -2;

  return 0;

}



inline P line_cp(const L &a, const L &b){

  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);

}



inline bool is_cp(const L &a, const L &b){

  return (ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)

    && (ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0);

}



inline P symmetry_line(const L &l, const P &p){

  if(abs(ccw(l.fs,l.sc,p)) != 1)return p;

  return line_cp(l, L(p,p + norm(l.fs-l.sc).fs))*2.0 - p;

}



struct state{

  P goal;

  vector<L> mirrors;

  state(P p, vector<L> m):goal(p),mirrors(m){}



  inline state symmetry(int x){

    vector<L> sym(mirrors.sz);

    rep(i,mirrors.sz){

      if(i == x)sym[i] = mirrors[i];

      else sym[i] = L(symmetry_line(mirrors[x],mirrors[i].fs),

		      symmetry_line(mirrors[x],mirrors[i].sc));

    }

    return state(symmetry_line(mirrors[x],goal), sym);

  }

};



const int max_depth = 6;

int n;

int tx,ty,lx,ly;



D rec(int depth, vector<int> &order, vector<state> &mir){

  if(depth == max_depth)return 1e8;

    D res = 1e8;



  bool f = true;

  P start = P(lx,ly);

  L route = L(start, mir.back().goal);

  rep(i,depth+1){

    state cur = mir[i];

    int axis = i==depth?-1:order[i], prev = !i?-1:order[i-1];

    if(axis>=0 && !is_cp(route, cur.mirrors[axis])){ f = false; break; }



    P cp = axis>=0?line_cp(route, cur.mirrors[axis]):mir.back().goal;

    L seg = L(start, cp);

    rep(j,n){

      if(axis!=j && prev!=j && is_cp(seg, cur.mirrors[j])){ f = false; break; }

    }

    if(!f)break;

    start = cp; route.fs = start;

  }

  if(f)res = abs(P(lx,ly) - mir.back().goal);



  rep(i,n){

    if(depth && order[depth-1] == i)continue;

    order.pb(i);

    mir.pb(mir.back().symmetry(i));

    res = min(res, rec(depth+1, order, mir) );

    mir.pop_back();

    order.pop_back();

  }



  return res;

}



int main(){

  while(scanf("%d",&n), n){

    vector<L> vl(n);

    rep(i,n){

      int px, py, qx, qy;

      scanf("%d%d%d%d",&px,&py,&qx,&qy);

      vl[i] = L(P(px,py), P(qx,qy));

    }

    scanf("%d%d%d%d",&tx,&ty,&lx,&ly);

    

    vector<state> vs;

    vs.push_back( state(P(tx,ty), vl) );

    vector<int> vi;

    printf("%.4lf\n",rec(0,vi,vs));

  }

}

// Fastest known solution for this problem: