#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 500;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


using speP = pair<ld, int>;

struct edge {
	int to; ld cost;
};
ld dist(P a, P b) {
	ld dx = b.first - a.first;
	ld dy = b.second - a.second;
	return sqrt(pow(dx, 2) + pow(dy, 2));
}

bool ison(P a, P l, P r) {
	ld cl = dist(a, l);
	ld cr = dist(a, r);
	ld cm = dist(l, r);
	return abs(cl + cr - cm) < eps;
}

int ban(P a, P b, P l, P r) {
	if (!ison(l, a, b))swap(l, r);
	int dx1 = b.first - a.first;
	int dy1 = b.second - a.second;
	int dx2 = r.first - l.first;
	int dy2 = r.second - l.second;
	int z = dx1 * dx2 + dy1 * dy2;
	if (z == 0)return 3;
	if (z > 0)return 1;
	if (z < 0)return 2;
}
int n;
void solve() {
	int cx[2], cy[2];
	rep(i, 2)cin >> cx[i] >> cy[i];
	vector<P> lep(n), rip(n);
	rep(i, n) {
		int x, y; cin >> x >> y;
		lep[i] = { x,y };
		cin >> x >> y;
		rip[i] = { x,y };
	}
	vector<bool> ism(n, false);
	rep(i, n) {
		P p = lep[i];
		int tmp = 0;
		rep(j, n) {
			if (i == j)continue;
			if (ison(p, lep[j], rip[j])) {
				tmp++; break;
			}
		}
		p = rip[i];
		rep(j, n) {
			if (i == j)continue;
			if (ison(p, lep[j], rip[j])) {
				tmp++; break;
			}
		}
		ism[i] = (tmp == 2);
		/*cout << i << " ! " << tmp << endl;
		if (ism[i]) {
			cout << "!! " << i << endl;
		}*/
	}
	vector<P> ps;
	rep(i, n) {
		if (!ism[i])continue;
		rep(j, n) {
			if (i == j)continue;
			if (!ism[j])continue;
			if (ison(lep[i], lep[j], rip[j])) {
				ps.push_back(lep[i]);
			}
			if (ison(rip[i], lep[j], rip[j])) {
				ps.push_back(rip[i]);
			}
		}
	}
	sort(all(ps));
	ps.erase(unique(all(ps)), ps.end());
	//cout << "! " << ps.size() << endl;
	//rep(i, ps.size())cout << ps[i].first << " " << ps[i].second << endl;
	vector<vector<pair<P, int>>> onp(n);
	rep(i, n) {
		rep(j, n) {
			if (i == j)continue;
			if (!ism[j])continue;
			int id = -1;
			if (!ism[i])id = i;
			if (ison(lep[i], lep[j], rip[j])) {
				onp[j].push_back({ lep[i],id });
			}
			if (ison(rip[i], lep[j], rip[j])) {
				onp[j].push_back({ rip[i],id });
			}
		}
	}
	rep(i, n) {
		onp[i].push_back({ lep[i],-1 });
		onp[i].push_back({ rip[i],-1 });
		sort(all(onp[i]));
		onp[i].erase(unique(all(onp[i])), onp[i].end());
	}
	map<P, int> mp;
	rep(i, ps.size())mp[ps[i]] = i;

	vector<vector<edge>> G(ps.size());
	rep(i, n) {
		if (!ism[i])continue;
		vector<int> ids;
		//cout << "???? " << i << endl;
		rep(j, onp[i].size()) {
			if (onp[i][j].second < 0) {
				ids.push_back(j);
				//cout << onp[i][j].first.first << " " << onp[i][j].first.second << endl;
			}
		}
		rep(j, (int)ids.size() - 1) {
			int leid = ids[j];
			int riid = ids[j + 1];
			bool fle = true, fri = true;
			for (int x = leid + 1; x <= riid - 1; x++) {
				int id = onp[i][x].second;
				int t = ban(onp[i][leid].first, onp[i][riid].first, lep[id], rip[id]);
				if (t & 1)fle = false;
				if (t & 2)fri = false;
			}
			int l = mp[onp[i][leid].first];
			int r = mp[onp[i][riid].first];
			if (fle) {
				//cout << l << " " << r << endl;
				G[l].push_back({ r,dist(ps[l],ps[r]) });
			}
			if (fri) {
				//cout << r << " " << l << endl;
				G[r].push_back({ l,dist(ps[r],ps[l]) });
			}
		}
	}
	vector<ld> dist(ps.size(),INF);
	vector<int> pre(ps.size(), -1);
	int sta = mp[{cx[0], cy[0]}];
	int goa = mp[{cx[1], cy[1]}];
	priority_queue<speP, vector<speP>, greater<speP>> q;
	dist[sta] = 0; q.push({ 0,sta });
	while (!q.empty()) {
		speP p = q.top(); q.pop();
		int id = p.second;
		if (dist[id] < p.first)continue;
		for (edge e : G[id]) {
			ld nd = dist[id] + e.cost;
			if (nd < dist[e.to]) {
				dist[e.to] = nd;
				pre[e.to] = id;
				q.push({ nd,e.to });
			}
		}
	}
	if (dist[goa] == INF) {
		cout << -1 << endl; return;
	}
	vector<P> memo;
	int cur = goa;
	while (cur != sta) {
		memo.push_back(ps[cur]);
		cur = pre[cur];
	}
	memo.push_back(ps[sta]);
	reverse(all(memo));
	rep(i, memo.size()) {
		cout << memo[i].first << " " << memo[i].second << endl;
	}
	cout << 0 << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f(); init();
	//int t; cin >> t; rep(i, t)solve();
	while (cin >> n, n)solve();
	stop
		return 0;
}


Measured memory_bytes: 3292