#include<iostream>
#include<complex>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>

using namespace std;

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

#define X real()
#define Y imag()

typedef complex<double> P;
typedef pair<P, P> L;
typedef vector<P> Pol;

const double INF = 1e40;
const double EPS = 1e-8;
const double PI = acos(-1);

int sig(double r) {return (r < -EPS) ? -1 : (r > EPS) ? 1: 0;}
bool eq(double a, double b) {return abs(a - b) < EPS;}
bool near(P a, P b) {return abs(b - a) < EPS;}

ostream &operator<<(ostream &os, const L &a) {
  os << a.first << "-" << a.second;
  return os;
}

double sq(double a) {return a * a;}

namespace std{
  bool operator<(const P &a, const P &b){
    if(!eq(a.X, b.X)) return a.X < b.X;
    if(!eq(a.Y, b.Y)) return a.Y < b.Y;
    return false;
  }
}

// ツ禿?静?
double dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
// ツ外ツ静?
double cross(P a, P b) {return a.X * b.Y - a.Y * b.X;}

// ツ静シツ閉ェabツづ可妥篠つキツづゥツ点xツづ個暗環置
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(const P a, P b, P x) {
  b -= a;
  x -= a;
  double cr = cross(b, x);
  if (eq(cr, 0)) {
    if (sig(dot(b, x)) < 0) return BACK;
    if (sig(abs(b) - abs(x)) < 0) return FRONT;
    return ON;
  }
  return (cr > 0) ? LEFT : RIGHT;
}

// ツ静シツ閉ェツづ個ベツクツトツδ?
P vec(L a) {return a.second - a.first;}

// ツ角ツ度
double arg(P a, P b) {return acos(dot(a, b) / (abs(a) * abs(b)));}
P polar(double r, double theta) {return P(r * cos(theta), r * sin(theta));}
P rot(P p, double theta) { return p * polar(1, theta);}

// ツ有ツ古シツ角ツ度
double varg(P a, P b) {
  double ret = arg(a) - arg(b);
  if (ret < 0) ret += 2 * PI;
  if (ret > 2 * PI) ret -= 2 * PI;
  if (eq(ret, 2 * PI)) ret = 0;
  return ret;
}

// ツ偲仰影
P proj(P a, P b) {return a * dot(a, b) / sq(abs(a));}
P perp(L l, P p) {return l.first + proj(vec(l), p - l.first);}
P refl(L l, P p) {return perp(l, p) * 2. - p;}
 
// ツ古ーツ債キツ板サツ津ィ ツ端ツ点ツづーツ甘慊づ?
bool iLL(L a, L b) {return !eq(cross(vec(a), vec(b)), 0);}
bool eqL(L a, L b) {return !iLL(a, b) && eq(cross(vec(a), b.first - a.first), 0);}
bool iLS(L a, L b) {return sig(cross(vec(a), b.first)) * sig(cross(vec(a), b.second)) <= 0;}
bool iSS(L a, L b) {
  int cwaf = ccw(a.first, a.second, b.first);
  int cwbf = ccw(b.first, b.second, a.first);
  int cwas = ccw(a.first, a.second, b.second);
  int cwbs = ccw(b.first, b.second, a.second);
  if ((cwaf | cwas | cwbf | cwbs) & ON) return true;
  return ((cwaf | cwas) & (cwbf | cwbs)) == (LEFT | RIGHT);
}
bool iSSs(L a, L b) {
  int cwaf = ccw(a.first, a.second, b.first);
  int cwbf = ccw(b.first, b.second, a.first);
  int cwas = ccw(a.first, a.second, b.second);
  int cwbs = ccw(b.first, b.second, a.second);
  return ((cwaf | cwas) & (cwbf | cwbs)) == (LEFT | RIGHT);
}

// ツ古ーツ点
P pLL(L a, L b) {
  P va = vec(a);
  P vb = vec(b);
  return a.first + va * (cross(vb, b.first - a.first) / cross(vb, va));
}

// ツ仰猟猟」
double dLP(L l, P x) {return abs(cross(vec(l), x - l.first)) / abs(vec(l));}
double dSP(L s, P x) {
  if (dot(vec(s), x - s.first) <= 0) return abs(x - s.first);
  if (dot(-vec(s), x - s.second) <= 0) return abs(x - s.second);
  return dLP(s, x);
}
double dLL(L a, L b) {return iLL(a, b) ? 0 : dLP(a, b.first);}
double dLS(L a, L b) {return iLS(a, b) ? 0 : min(dLP(a, b.first), dLP(a, b.second));}
double 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)));}

vector<L> mirror;
P tp, lp;
int n;

bool g(P a, P b, vector<int> pre) {
  if (pre.size() == 0) {
    bool ok = true;
    rep (i, mirror.size()) if (iSSs(L(a, b), mirror[i])) ok = false;
    return ok;
  }
  L l = mirror[pre[pre.size() - 1]];
  if (!iSS(l, L(a, b))) return false;
  P p = pLL(l, L(a, b));
  rep (i, mirror.size()) if (iSSs(mirror[i], L(p, b))) return false;
  a = refl(l, a);
  pre.pop_back();
  return g(a, p, pre);
}

double f(P a, int m, vector<int> pre) {
  double res = INF;
  if (g(a, lp, pre)) res = abs(a - lp);
  if (m == 0) return res;
  rep (i, n) {
    if (pre.size() > 0 && i == pre[pre.size() - 1]) continue;
    pre.push_back(i);
    res = min(res, f(refl(mirror[i], a), m - 1, pre));
    pre.pop_back();
  }
  return res;
}

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;
    mirror.clear();
    rep (i, n) {
      int px, py, qx, qy;
      cin >> px >> py >> qx >> qy;
      mirror.push_back(L(P(px, py), P(qx, qy)));
    }
    cin >> tp.X >> tp.Y >> lp.X >> lp.Y;
    vector<int> v;
    printf("%.12lf\n", f(tp, 5, v));
  }
}

Measured memory_bytes: 0