#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-11)
#define mod 1000000007
#define pi acos(-1)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
  bool operator==(Segment s)const{
    if(s.p1==p1 && s.p2==p2)return true;
    if(s.p2==p1 && s.p1==p2)return true;
    return false;
  }
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

Point project(Segment s,Point p){
  Vector base=(s.p2-s.p1);
  double r=(dot(p-s.p1,base)/base.norm());
  return (s.p1+base*r);
}

Point reflect(Segment s,Point p){
  return p+(project(s,p)-p)*2;
}

Segment reflect(Segment s,Segment t){
  return Segment(reflect(s,t.p1),reflect(s,t.p2));
}

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return 1;
  if(cross(a,b)<-eps)return -1;
  if(dot(a,b)<-eps)return 2;
  if(a.norm()<b.norm())return -2;
  return 0;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

Point getCrossPointLL(Line a,Line b){
  double A=cross(a.p2-a.p1,b.p2-b.p1);
  double B=cross(a.p2-a.p1,a.p2-b.p1);
  if(abs(A)<eps || abs(B)<eps)return b.p1;
  return b.p1+(b.p2-b.p1)*(B/A);
}

int n;
Point s,t;

typedef vector<Segment> VS;

void p(VS v){
  FOR(i,0,v.size()){
    cout<<v[i].p1.x<<" "<<v[i].p1.y<<" ";
    cout<<v[i].p2.x<<" "<<v[i].p2.y<<endl;
  }
}

double check(VS used,vector<VS> vvs,Point rt){
  vector<Point> vp;
  vp.pb(s);
  FOR(i,0,used.size()){
    if(!intersect(used[i],Segment(s,rt)))return inf;
    vp.pb(getCrossPointLL(used[i],Segment(s,rt)));
  }
  vp.pb(rt);
  int c=0;
  FOR(i,2,vp.size())c+=ccw(vp[i-2],vp[i-1],vp[i]);
  if(abs(c)!=vp.size()*2-4)return inf;
  FOR(i,0,vvs.size()){
    FOR(j,0,vvs[i].size()){
      if(!intersect(Line(s,rt),vvs[i][j]))continue;
      Point m=getCrossPointLL(Line(s,rt),vvs[i][j]);
      if(m==vp[i] || m==vp[i+1])continue;
      if(ccw(vp[i+1],vp[i],m)==0)return inf;
    }
  }
  return abs(s-rt);
}

double rec(VS vs,VS used,vector<VS> vvs,Point rt){
  if(6<=used.size())return inf;
  vvs.pb(vs);
  double res = check(used,vvs,rt);
  FOR(i,0,vs.size()){
    if(used.size() && vs[i]==used.back())continue;
    VS rvs;
    FOR(j,0,vs.size())rvs.pb(reflect(vs[i],vs[j]));
    used.pb(vs[i]);
    res=min(res,rec(rvs,used,vvs,reflect(vs[i],rt)));
    used.pop_back();
  }
  return res;
}

int main()
{
  while(cin>>n && n){
    vector<Segment> vs,used;
    vector<vector<Segment> > vvs;
    FOR(i,0,n){
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      vs.pb(Segment(Point(a,b),Point(c,d)));
    }
    cin>>s.x>>s.y>>t.x>>t.y;
    pd(rec(vs,used,vvs,t));
  }
  return 0;
}

Measured memory_bytes: 3168