#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef double D;
typedef complex<D> P;
typedef pair<P,P>L;
typedef vector<L> VP;
const D EPS = 1e-9;
#define mk make_pair
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D ans,sx,sy,gx,gy,x,y,xx,yy;
VP v,t;
int num[7];
int n;
D dot(P a,P b){return (conj(a)*b).X;}
D cross(P a,P b){return (conj(a)*b).Y;}
int ccw(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(norm(b)<norm(c))return -2;
  return 0;
}
bool isecSS(P a1, P a2, P b1, P b2){
  return ccw(a1,a2,b1)*ccw(a1,a2,b2)<=0 &&
         ccw(b1,b2,a1)*ccw(b1,b2,a2)<=0;
}
P proj(P a1,P a2,P p){
  return a1+ dot(a2-a1,p-a1)/norm(a2-a1)*(a2-a1);
}
P reflection(P a1, P a2, P p) {
  return 2.0*proj(a1, a2, p) - p;
}
P crosspointSS(P a1,P a2,P b1,P b2){
  P base=b2-b1;
  double d1=abs(cross(base,a1-b1));
  double d2=abs(cross(base,a2-b1));
  double t=d1/(d1+d2);
  return a1+(a2-a1)*t;
}
bool isecSP(P a1, P a2, P b) {
  //return !ccw(a1, a2, b);
   return abs(a1 - b) + abs(a2 - b) - abs(a2 - a1) < EPS;  //Perfect
}
D distSP(P a1, P a2, P p) {
  P r = proj(a1, a2, p);
  if (isecSP(a1, a2, r)) return abs(r-p);
  return min(abs(a1-p), abs(a2-p));
}
int n_max,flag,cnt;
 
VP ch,c7[8];
P c8[9];
P start, en;
vector<pair<double,int> >vv;

void dfs2(int dep){
 
 
  r(i,n)if(i!=num[dep]){
    if(!(dep&&i==num[dep-1]))c7[dep].push_back(t[i]);
  }
 
   
  if(n_max==dep){
    vv.clear();
    r(i,ch.size()){
      if(!isecSS( ch[i].first, ch[i].second, start, en)) flag ++;
      vv.push_back(mk(distSP(ch[i].first,ch[i].second,en),i));
    }
    sort(vv.begin(),vv.end());
    r(i,(int)vv.size()-1){
      if(vv[i].second<vv[i+1].second)flag++;
    }

    c8[0]=start;
    for(int i=0;i<dep;i++){
      c8[i+1]=crosspointSS(start,en,ch[i].first,ch[i].second);
    }
    c8[dep+1]=en;
    
    r(i,c7[dep].size()){
      if(isecSS( c7[dep][i].first, c7[dep][i].second, c8[dep], c8[dep+1])) flag ++;
    }
    return ;
  }
 
  ch.push_back(t[num[dep]]);
 
   P ss = t[num[dep]].first;
   P gg = t[num[dep]].second;
 
    
 
  for(int i=0;i<n;i++){
    if(num[dep]!=i){
      t[i].first=reflection(ss,gg,t[i].first);
      t[i].second=reflection(ss,gg,t[i].second);
    }
  }
  en = reflection(ss,gg,en);
   
  dfs2(dep+1);
 
  if(flag)return ;
 
 
  r(i,c7[dep].size()){
      if(isecSS( c7[dep][i].first, c7[dep][i].second, c8[dep], c8[dep+1])) flag ++;
  }
  return ;
}
void dfs1(int dep,int pre){
 
  if(dep==6) return ;
 
  start=P(sx,sy);
  en=P(gx,gy);
  ch.clear();
  t.clear();
  r(i,8)c7[i].clear();
  flag = 0;
  n_max = dep;
  r(i,n)t.push_back(v[i]);
   
  dfs2(0);
 
  if(!flag)ans=min(ans,abs(start-en));
 
  for(int i=0;i<n;i++){
    if(pre!=i){
      num[dep]=i;
      dfs1(dep+1,i);
      num[dep]=-1;
    }
  }
}
 
int main(){
  while(cin>>n,n){
    memset(num,-1,sizeof(num));
    ans=1e13;
    v.clear();
    r(i,n){
      cin >> x >> y >> xx >> yy;
      v.push_back( mk( P(x,y) , P(xx,yy) ) );
    }
    cin >> gx >> gy >> sx >> sy ;
    dfs1(0,-1);
    printf("%.13f\n",ans);
  }
}