#include <vector>
#include <complex>
#include <cmath>
#include <iostream>
#include <map>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef complex<double> Point;
const double EPS = 1e-8;
const double INF = 1e16;

namespace std{
    bool operator < (const Point& p, const Point& q){
        if(p.real() != q.real()) return p.real() < q.real();
        return p.imag() < q.imag();
    }
}

struct Line : public vector<Point> {
    Line(const Point& a, const Point& b) {
        push_back(a); push_back(b);
    }
    Point vector() const {
        return back() - front();
    }
};

void insert(Point p, map<Point, int>& index, vector<Point>& vp){
    if(!index.count(p)){
        int t = index.size();
        vp.push_back(p);
        index[p] = t;
    }
}

int sign(double x){
    if(x > EPS) return 1;
    if(x < -EPS) return -1;
    return 0;
}

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

double 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;
    if(cross(b, c) < -EPS) return -1;
    if(dot(b, c) < 0) return 2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

bool intersectSP(Line s, Point p) {
    return ccw(s[0], s[1], p) == 0;
}

bool online(Point p, vector<Line>& lv, int k){
    for(int i = 0; i < lv.size(); i++) if(i != k) {
        if(intersectSP(lv[i], p)) return true;
    }
    return false;
}

bool online(Point p, Point q, vector<Line>& lv, vector<bool>& is_road){
    for(int i = 0; i < lv.size(); i++){
        if(is_road[i] && intersectSP(lv[i], p) && intersectSP(lv[i], q)) return true;
    }
    return false;
}

int main(){
    int N;
    while(cin >> N && N){
        map<Point, int> index;
        vector<Point> vp;
        double sx, sy, gx, gy;
        cin >> sx >> sy >> gx >> gy;
        Point sp(sx, sy);
        Point gp(gx, gy);
        insert(sp, index, vp);
        insert(gp, index, vp);

        vector<Line> lv;
        REP(i, N){
            double x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;
            Point p1(x1, y1);
            Point p2(x2, y2);
            lv.push_back(Line(p1, p2));
        }
        vector<bool> is_road(N, false);
        for(int i = 0; i < N; i++){
            if(online(lv[i][0], lv, i) && online(lv[i][1], lv, i)){
                is_road[i] = true;
            }
        }

        for(int i = 0; i < N; i++) if(is_road[i]){
            insert(lv[i][0], index, vp);
            insert(lv[i][1], index, vp);
        }

        int M = vp.size();
        double dist[500][500] = {};
        REP(i, M) REP(j, M) dist[i][j] = INF;
        REP(i, M) REP(j, M) if(i != j && online(vp[i], vp[j], lv, is_road)) {
            Line s(vp[i], vp[j]);
            bool ok = true;
            for(int k = 0; k < N; k++) if(!is_road[k] && (intersectSP(s, lv[k][0]) || intersectSP(s, lv[k][1]))){
                if(intersectSP(s, lv[k][1])) swap(lv[k][0], lv[k][1]);
                if(sign(dot(lv[k].vector(), s[1] - lv[k][0])) >= 0) ok = false;
            }
            if(ok) dist[i][j] = abs(s.vector());
        }
        vector<double> shortest(M, INF);
        vector<int> back(M, -1);
        shortest[ index[sp] ] = 0;
        REP(iter, M){
            REP(i, M) REP(j, M) if(dist[i][j] != INF) {
                if((shortest[j] > shortest[i] + dist[i][j]) ||
                   (shortest[j] == shortest[i] + dist[i][j] && dist[i][j] < dist[back[j]][j])){
                    shortest[j] = shortest[i] + dist[i][j];
                    back[j] = i;
                }
            }
        }

        if(shortest[ index[gp] ] == INF){
            cout << -1 << endl;
        }else{
            vector<pair<int, int>> ans;
            int k = index[gp];
            while(k != -1){
                ans.push_back(pair<int, int>((int)vp[k].real(), (int)vp[k].imag()));
                k = back[k];
            }
            for(int i = ans.size() - 1; i >= 0; i--){
                cout << ans[i].first << " " << ans[i].second << endl;
            }
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3252