#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <complex>
#include <cfloat>
#include <queue>
#include <functional>
#include <stack>
using namespace std;

#define EPS 1e-7

typedef pair<double,int> pdi;

typedef complex<int> point;
typedef const point &rpoint;


//あんまりやりたくないけど
namespace std{
	inline bool operator<(rpoint p1, rpoint p2){
		if(p1.real() != p2.real()) return p1.real() < p2.real();
		return p1.imag() < p2.imag();
	}
}


int dot(rpoint va, rpoint vb){
	return va.real() * vb.real() + va.imag() * vb.imag();
}

int cross(rpoint va, rpoint vb){
	return real(va) * imag(vb) - imag(va) * real(vb);
}


double distance_pp(rpoint a, rpoint b){
	return sqrt(norm(a - b));
}


bool contains(rpoint a1, rpoint a2, rpoint b){
	return abs(distance_pp(a1, b) + distance_pp(a2, b) - distance_pp(a1, a2)) < EPS;
}


void solve(const vector<pair<point,point> > &lines, rpoint pstart, rpoint pgoal ){
	vector<pair<point,point> > street, sign;

	int n = lines.size();
	for(int i = 0; i < n; ++i){
		bool f1 = false, f2 = false;
		for(int j = 0; j < n; ++j){
			if( i == j ) continue;
			if( contains(lines[j].first, lines[j].second, lines[i].first) ){
				f1 = true;
				break;
			}
		}
		for(int j = 0; j < n; ++j){
			if( i == j ) continue;
			if( contains(lines[j].first, lines[j].second, lines[i].second) ){
				f2 = true;
				break;
			}
		}
		
		if( f1 && f2 ){
			street.push_back( lines[i] );
		}
		else{
			sign.push_back( lines[i] );
		}
	}

	map<point,int> mp;
	for(int i = 0; i < street.size(); ++i){
		mp.insert( make_pair( street[i].first, mp.size() ) );
		mp.insert( make_pair( street[i].second, mp.size() ) );
	}

	vector<point> V( mp.size() );
	for(map<point,int>::iterator it = mp.begin(); it != mp.end(); ++it){
		V[it->second] = it->first;
	}

	vector<vector<pdi> > intr(street.size());
	vector<vector<char> > flags(street.size());

	for(int i = 0; i < street.size(); ++i){
		intr[i].push_back( pdi(0.0, mp[street[i].first]) );

		for(int j = 0; j < street.size(); ++j){
			if( i == j ) continue;
			
			if( contains(street[i].first, street[i].second, street[j].first) ){
				int k = mp[street[j].first];
				intr[i].push_back( pdi(distance_pp(street[i].first, street[j].first), k) );
			}
			if( contains(street[i].first, street[i].second, street[j].second) ){
				int k = mp[street[j].second];
				intr[i].push_back( pdi(distance_pp(street[i].first, street[j].second), k) );
			}
		}

		sort(intr[i].begin(), intr[i].end());
		intr[i].push_back( pdi(distance_pp(street[i].first, street[i].second), mp[street[i].second]) );

		flags[i].resize(intr[i].size(), 3);
	}
	
	for(int i = 0; i < sign.size(); ++i){
		bool f = true;

		for(int j = 0; j < street.size() && f; ++j){
			for(int k = 1; k < intr[j].size(); ++k){
				rpoint p1 = V[ intr[j][k-1].second ];
				rpoint p2 = V[ intr[j][k].second ];

				if(	contains(p1, p2, sign[i].first) ){
					int a = dot(p2 - p1, sign[i].second - sign[i].first);

					if( a >= 0 ){
						flags[j][k] &= ~1;
					}
					if( a <= 0 ){
						flags[j][k] &= ~2;
					}
					f = false;
					break;
				}
				if(	contains(p1, p2, sign[i].second) ){
					int a = dot(p2 - p1, sign[i].first - sign[i].second);

					if( a >= 0 ){
						flags[j][k] &= ~1;
					}
					if( a <= 0 ){
						flags[j][k] &= ~2;
					}
					f = false;
					break;
				}
			}
			
		}
	}
	
	vector<vector<pdi> > edge( V.size() );
	for(int i = 0; i < intr.size(); ++i){
		for(int j = 1; j < intr[i].size(); ++j){
			int a = intr[i][j-1].second;
			int b = intr[i][j].second;
			double d = intr[i][j].first - intr[i][j-1].first;

			if( flags[i][j] & 1 ){
				edge[a].push_back( pdi(d, b) );
			}
			if( flags[i][j] & 2 ){
				edge[b].push_back( pdi(d, a) );
			}
		}
	}
	
	vector<int> from(V.size(), -1);
	vector<double> dist(V.size(), DBL_MAX);

	int start = mp[pstart];
	int goal = mp[pgoal];
	dist[start] = 0.0;
	
	priority_queue<pdi,vector<pdi>,greater<pdi> > pq;
	pq.push( pdi(0.0, start) );
	while( !pq.empty() ){
		pdi p = pq.top();
		pq.pop();
		
		if( p.first != dist[p.second] ) continue;

		for(int i = 0; i < edge[p.second].size(); ++i){
			double d = p.first + edge[p.second][i].first;
			int to = edge[p.second][i].second;

			if( dist[to] > d ){
				dist[to] = d;
				from[to] = p.second;
				pq.push( pdi(d, to) );
			}
		}
	}

	if( from[goal] == -1 ){
		puts("-1");
		return;
	}

	stack<int> stc;
	for(int p = goal; p != start; p = from[p] ){
		stc.push(p);
	}
	stc.push(start);

	while( !stc.empty() ){
		int p = stc.top();
		stc.pop();
		printf("%d %d\n", V[p].real(), V[p].imag() );
	}
	puts("0");
}


int main(){
	int n, xs, ys, xg, yg;
	while(scanf("%d%d%d%d%d", &n, &xs, &ys, &xg, &yg) == 5){
		vector<pair<point,point> > lines;
		lines.reserve(n);
		
		int x1, y1, x2, y2;
		for(int i = 0; i < n; ++i){
			scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
			lines.push_back( make_pair(point(x1, y1), point(x2, y2) ) );
		}
		
		solve( lines, point(xs, ys), point(xg, yg) );
	}
}