#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;


typedef complex<double> P;
namespace std {
bool operator < (const P& a, const P& b) {
  // if (abs(a-b)<EPS) return 0;
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
};
typedef vector<P> G;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
    abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
    cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
    ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSS2(const L &s, const L &t) { // 接しているやつは交差と考えない
  REP(i, 2) {
    if (ccw(s[0], s[1], t[i]) == 0) {
      int c = ccw(s[0],s[1],t[!i]);
      if (s[0] == t[i]) {
        if (c!=-2&&c) return 0;
      } else if (s[1] == t[i]) {
        if (c!=2&&c) return 0;
      } else if (abs(c)==1) return 0;
    }
  }
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
P reflection(const L &l, const P &p) {
  return p + P(2,0) * (projection(l, p) - p);
}
L reflection(const L &l, const L &m) {
  return L(reflection(l,m[0]), reflection(l,m[1]));
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}


L l[5];
P target;
P lazer;
int n;
typedef pair<double, int> pdi;

double func(vector<int> v) {
  vector<L> nowlv;
  REP(i,v.size()) nowlv.push_back(l[v[i]]);
  // calc target
  P tar = target;
  REP(i, nowlv.size()) {
    tar = reflection(nowlv[i], tar);
    for (int j=i+1; j<nowlv.size(); ++j) {
      if (v[i] == v[j]) continue;
      nowlv[j] = reflection(nowlv[i], nowlv[j]);
    }
  }
  nowlv.clear();
  REP(i,v.size()) nowlv.push_back(l[v[i]]);
  
  //
  P now = lazer;
  vector<L> nowls;
  REP(i, n) nowls.push_back(l[i]);
  // if (v.size() == 2 && v[0] == 1 && v[1] == 0) {
  //   FOR(it, v) cout << *it << " "; cout <<endl;
  //   cout << tar << endl;
  // }

  REP(i, nowlv.size()) {
    L s(now, tar);
    double mi = INF;
    int id = -1;
    P next;
    REP(j,n) {
      if (intersectSS2(s, nowls[j])) {
        P cp = crosspoint(s, nowls[j]);
        double d = abs(cp-now);
        if (d > EPS && d < mi) {
          next = cp;
          mi = d;
          id = j;
        }
      }
      if (v[i] == j) continue;
      nowls[j] = reflection(nowlv[i], nowls[j]);
    }
    // if (v.size() == 2 && v[0] == 1 && v[1] == 0) {
    //   cout << "id = " << id << endl;
    //   cout << "now = " << now << endl;
    //   cout << "next = " << next << endl;
    //   cout << "mi = " << mi << endl;
    //   FOR(it, nowls) {
    //     cout << (*it)[0] << "->" << (*it)[1] << endl;
    //   }
    // }

    if (id != v[i]) return INF;
    now = next; 
   
    
    for (int j=i+1; j<nowlv.size(); ++j) {
      if (v[i] == v[j]) continue;
      nowlv[j] = reflection(nowlv[i], nowlv[j]);
    }
  }
  L s(now,tar);

  double mi = INF;
  int id = -1;
  P next;
  REP(j,n) {
    if (intersectSS2(s, nowls[j])) {
      P cp = crosspoint(s, nowls[j]);
      double d = abs(cp-now);
      if (d > EPS && d < mi) {
        next = cp;
        mi = d;
        id = j;
      }
    }
  }
  if (id != -1) return INF;


  return abs(lazer-tar);
}

double solve(vector<int> v) {
  int m;
  m = v.size();
  double res = INF;

  res = min(res, func(v));

  
  if (m == 5) return res;
  v.push_back(0);
  REP(i,n) {
    if (m > 0 && v[m-1] == i) continue;
    v[m] = i;
    res = min(res, solve(v));
  }
  return res;
}

int main() {
  while(cin>>n,n) {
    REP(i,n) {
      P a, b;
      cin >> a.real() >> a.imag() >> b.real() >> b.imag();
      l[i] = L(a,b);
    }
    cin>>target.real()>>target.imag();
    cin>>lazer.real()>>lazer.imag();
    vector<int> v;
    double ans = solve(v);
    printf("%.14f\n", ans);
  }
}

Measured memory_bytes: 1012