#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Point{
	double x,y;
	Point(){};
	Point(double x,double y):x(x),y(y){}
};
bool operator==(Point a,Point b){
	return abs(a.x-b.x)<EPS && abs(a.y-b.y)<EPS;
}
Point operator+(Point a,Point b){
	return Point(a.x+b.x,a.y+b.y);
}
Point operator-(Point a,Point b){
	return Point(a.x-b.x,a.y-b.y);
}
Point operator*(double c,Point p){
	return Point(c*p.x,c*p.y);
}
Point operator/(Point p,double c){
	return Point(p.x/c,p.y/c);
}
struct Line{
	Point pos,dir;
	Line(){}
	Line(Point p,Point d):pos(p),dir(d){}
};
typedef Line Segment;

ostream& operator<<(ostream& os,const Point& p){return os<<mp(p.x,p.y);}
ostream& operator<<(ostream& os,const Line& l){return os<<mp(l.pos,l.dir);}

struct LessX{
	bool operator()(Point a,Point b){
		return a.x<b.x-EPS || (a.x<b.x+EPS && a.y<b.y-EPS);
	}
};

int Signum(double x){
	return abs(x)<EPS?0:x<0?-1:1;
}
double Dot(Point a,Point b){
	return a.x*b.x+a.y*b.y;
}
double Cross(Point a,Point b){
	return a.x*b.y-a.y*b.x;
}
double Abs(Point p){
	return sqrt(p.x*p.x+p.y*p.y);
}
double Abs2(Point p){
	return p.x*p.x+p.y*p.y;
}
int CCW(Point a,Point b,Point c){
	Point d1=b-a,d2=c-a;
	if(int sign=Signum(Cross(d1,d2)))
		return sign;	// 1:ccw,-1:cw
	if(Dot(d1,d2)<-EPS)
		return -2;		// c-a-b
	if(Abs2(d1)<Abs2(d2)-EPS)
		return 2;		// a-b-c
	return 0;			// a-c-b
}
bool IsInterSS(Segment a,Segment b){
	int c1=CCW(a.pos,a.pos+a.dir,b.pos),c2=CCW(a.pos,a.pos+a.dir,b.pos+b.dir);
	int c3=CCW(b.pos,b.pos+b.dir,a.pos),c4=CCW(b.pos,b.pos+b.dir,a.pos+a.dir);
	return c1*c2<=0 && c3*c4<=0;
}
bool IsInterSP(Segment s,Point p){
	return CCW(s.pos,s.pos+s.dir,p)==0;
}
Point InterLL(Line a,Line b){
	if(abs(Cross(a.dir,b.dir))<EPS)
		return a.pos;
	return a.pos+Cross(b.pos-a.pos,b.dir)/Cross(a.dir,b.dir)*a.dir;
}
Point InterSS(Segment a,Segment b){
	assert(IsInterSS(a,b));
	if(abs(Cross(a.dir,b.dir))<EPS){
		if(IsInterSP(b,a.pos)) return a.pos;
		if(IsInterSP(b,a.pos+a.dir)) return a.pos+a.dir;
		if(IsInterSP(a,b.pos)) return b.pos;
		if(IsInterSP(a,b.pos+b.dir)) return b.pos+b.dir;
	}
	return InterLL(a,b);
}

struct Edge{
	int src,dst;
	double weight;
	Edge(){}
	Edge(int s,int d,double w):src(s),dst(d),weight(w){}
	bool operator<(const Edge& e)const{return weight<e.weight-EPS;}
	bool operator>(const Edge& e)const{return weight>e.weight+EPS;}
};
typedef vector<vector<Edge> > Graph;

void SegmentArrangement(const vector<Segment>& ss,Graph& g,vector<Point>& ps)
{
	rep(i,ss.size()){
		ps.push_back(ss[i].pos);
		ps.push_back(ss[i].pos+ss[i].dir);
		repi(j,i+1,ss.size()) if(IsInterSS(ss[i],ss[j]))
			ps.push_back(InterSS(ss[i],ss[j]));
	}
	sort(all(ps),LessX());
	ps.erase(unique(all(ps)),ps.end());
	
	g.resize(ps.size());
	rep(i,ss.size()){
		vector<pair<double,int> > ds;
		rep(j,ps.size()) if(IsInterSP(ss[i],ps[j]))
			ds.push_back(mp(Abs(ps[j]-ss[i].pos),j));
		sort(all(ds));
		rep(j,ds.size()-1){
			int u=ds[j].second,v=ds[j+1].second;
			double w=ds[j+1].first-ds[j].first;
			g[u].push_back(Edge(u,v,w));
			g[v].push_back(Edge(v,u,w));
		}
	}
}

int main()
{
	for(int n;cin>>n,n;){
		Point start,goal; cin>>start.x>>start.y>>goal.x>>goal.y;
		vector<Segment> segs(n);
		rep(i,n){
			double x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
			segs[i]=Segment(Point(x1,y1),Point(x2-x1,y2-y1));
		}
		
		vector<Segment> streets,signs;
		rep(i,n){
			Point p1=segs[i].pos,p2=segs[i].pos+segs[i].dir;
			bool flg1=false,flg2=false;
			rep(j,n) if(i!=j){
				flg1|=IsInterSP(segs[j],p1);
				flg2|=IsInterSP(segs[j],p2);
			}
			if(flg1&&flg2) streets.push_back(segs[i]);
			else           signs.push_back(segs[i]);
		}
		rep(i,signs.size()) rep(j,streets.size())
			if(IsInterSP(streets[j],signs[i].pos+signs[i].dir))
				signs[i]=Segment(signs[i].pos+signs[i].dir,-1*signs[i].dir);
		
		vector<Point> ps(2);
		ps[0]=start,ps[1]=goal;
		Graph g;
		SegmentArrangement(streets,g,ps);
		int m=g.size();
		
		// 標識に基づいて辺を削除
		rep(i,signs.size()){
			rep(j,g.size()) rep(k,g[j].size()){
				int u=j,v=g[j][k].dst;
				Segment seg(ps[u],ps[v]-ps[u]);
				if(IsInterSP(seg,signs[i].pos) && Dot(seg.dir,signs[i].dir)>-EPS)
					g[j].erase(g[j].begin()+k--);
			}
		}
		
		int si=-1,gi=-1;
		rep(i,m){
			if(ps[i]==start) si=i;
			if(ps[i]==goal)  gi=i;
		}
		
		vd dist(m,INFTY); vi prev(m,-1);
		priority_queue<Edge,vector<Edge>,greater<Edge> > pq;
		pq.push(Edge(-1,si,0));
		while(!pq.empty()){
			Edge cur=pq.top(); pq.pop();
			if(dist[cur.dst]!=INFTY) continue;
			dist[cur.dst]=cur.weight;
			prev[cur.dst]=cur.src;
			foreach(e,g[cur.dst])
				pq.push(Edge(e->src,e->dst,cur.weight+e->weight));
		}
		
		if(dist[gi]==INFTY)
			cout<<-1<<endl;
		else{
			vector<Point> res;
			for(int i=gi;i!=-1;i=prev[i])
				res.push_back(ps[i]);
			per(i,res.size())
				cout<<res[i].x<<' '<<res[i].y<<endl;
			cout<<0<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1364