#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef long double ld;
const ld PI = acos(-1.0);
bool eq(ld a, ld b) { return abs(a - b) < EPS; }
typedef complex<ld> Point;
typedef vector<Point> Polygon;

namespace std
{
	bool operator < (const Point& a, const Point& b)
	{
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

struct Line
{
	Point a, b;
	Line() {};
	Line(Point p, Point q) :a(p), b(q) {};
	Line(ld x1, ld y1, ld x2, ld y2) :a(Point(x1, y1)), b(Point(x2, y2)) {};
};

ld dot(Point a, Point b)
{
	return real(conj(a)*b);
}

ld cross(Point a, Point b)
{
	return imag(conj(a)*b);
}

int ccw(Point a, Point b, Point c)
{
	b -= a; c -= a;
	if (cross(b, c) > EPS) return 1;    //counter cloclwise
	if (cross(b, c) < -EPS) return -1;  //cloclwise
	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;                           //a--c--b on line
}

bool isis_ll(Line l, Line m)
{
	return abs(cross(l.b - l.a, m.b - m.a)) > EPS;
}

bool isis_ls(Line l, Line s)
{
	return cross(l.b - l.a, s.a - l.a)*cross(l.b - l.a, s.b - l.a) < EPS;
}

bool isis_ss(Line s, Line t)
{
	return (ccw(s.a, s.b, t.a)*ccw(s.a, s.b, t.b) <= 0 &&
		ccw(t.a, t.b, s.a)*ccw(t.a, t.b, s.b) <= 0);
}

bool isis_sp(Line s, Point p)
{
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a)) < EPS;
}

Point projection(Line l, Point p)
{
	Point base = l.b - l.a;
	ld r = dot(p - l.a, base) / norm(base);
	return l.a + base*r;
}

Point mirror(Line l, Point p)
{
	Point res = Point(2, 0)*projection(l, p) - p;
	return res;
}

Point is_ll(Line s, Line t)
{
	ld a = cross(s.b - s.a, t.b - t.a);
	ld b = cross(s.b - s.a, s.b - t.a);
	return t.a + b / a*(t.b - t.a);
}

vector<vi> make_per(int use, int n)
{
	vi v = {};
	queue<vi> que;
	que.push(v);
	vector<vi> res;
	while (que.size())
	{
		vi t = que.front(); que.pop();
		if (t.size() == use)
		{
			res.push_back(t);
		}
		else
		{
			REP(i, n)
			{
				vi nx = t;
				nx.push_back(i);
				que.push(nx);
			}
		}
	}
	return res;
}

bool isis_ss_edge(Line s, Line t)
{
	if (!isis_ss(s, t)) return false;
	if (isis_sp(t, s.a) || isis_sp(t, s.b) || isis_sp(s, t.a) || isis_sp(s, t.b)) return false;
	return true;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n;
	while (cin >> n, n)
	{
		vector<Line> mirrors(n);
		REP(i, n)
		{
			ld a, b, c, d; cin >> a >> b >> c >> d;
			mirrors[i] = Line(a, b, c, d);
		}
		ld sx, sy, gx, gy;
		cin >> sx >> sy >> gx >> gy;
		Point st(sx, sy), go(gx, gy);
		ld ans = INF;
		REP(use, 6)
		{
			vector<vi> per = make_per(use, n);
			for (auto tper : per)
			{
				Point tmpg = go;
				for (int i = tper.size() - 1; i >= 0; i--)
				{
					tmpg = mirror(mirrors[tper[i]], tmpg);
				}
				vector<Line> tmp_mirrors = mirrors;
				bool f = true;
				Line light(st, tmpg);
				ld len = abs(light.a - light.b);

				REP(i, tper.size() + 1)
				{
					int col = -1;
					Point p(tmpg);
					REP(j, n)
					{
						if (isis_ss_edge(light, tmp_mirrors[j]))
						{
							Point tp = is_ll(light, tmp_mirrors[j]);
							if (abs(light.a - p) - abs(light.a - tp) > EPS)
							{
								col = j;
								p = tp;
							}
						}
					}
					if (i != tper.size())
					{
						if (col != tper[i])
						{
							f = false;
							break;
						}
						REP(j, tmp_mirrors.size())
						{
							Line tmpl(tmp_mirrors[j]);
							Line mir_tmpl(mirror(tmp_mirrors[tper[i]], tmpl.a), mirror(tmp_mirrors[tper[i]], tmpl.b));
							tmp_mirrors[j] = mir_tmpl;
						}
						light.a = p;
					}
					else
					{
						if (col != -1)
						{
							f = false;
							break;
						}
					}
				}
				if (f) chmin(ans, len);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3536