#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <complex>
#include <cmath>
#include <vector>
#include <set>
using namespace std;
typedef complex<double> P;
const double eps = 1e-8;
const double pi = acos(-1);
const int INF = 1<<28;

bool equals(double a, double b) { return abs(a-b) < eps; }

namespace std {
  bool operator < (const P &a, const P &b) {
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
  }
}

struct L : public vector<P> {
  L() : vector<P>(2) {}
  L(P a, P b) {
    push_back(a);
    push_back(b);
  }
};

double dot(P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }
double cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }


int ccw(P p0, P a, P b) {
  a -= p0;
  b -= p0;
  if(cross(a,b) > eps) return 1;
  if(cross(a,b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(a) < norm(b)) return -2;
  return 0;
}

double getAngle(P a, P b) {
  return acos(dot(a,b)/(abs(a)*abs(b)));
}

// ----------------------------------------

const int MAX_N = 410;
vector<L> ls;
map<P,int> id;
map<int,P> id2;
vector<pair<int,double> > E[MAX_N];

P start, goal;

void init() {
  ls.clear();
  id.clear();
  id2.clear();
  for(int i = 0; i < MAX_N; ++i) E[i].clear();
}

int getId(P a) {
  if(!id.count(a)) {
    int tmp = id.size();
    id[a] = tmp;
    id2[tmp] = a;
  }
  return id[a];
}

void addEdge(P a, P b) {
  double cost = abs(a-b);
  E[getId(a)].push_back(make_pair(getId(b),cost));
}

int makeG() {
  vector<P> ps;
  vector<L> sign;

  for(int i = 0; i < ls.size(); ++i) {
    int s = 0;
    for(int j = 0; j < ls.size() && s != 3; ++j) {
      if(i == j) continue;
      if(!ccw(ls[j][0],ls[j][1],ls[i][0])) s |= 1;
      if(!ccw(ls[j][0],ls[j][1],ls[i][1])) s |= 2;
    }
    if(s != 3) {
      sign.push_back(ls[i]);
      ls.erase(ls.begin()+i);
      --i;
    }
  }

  for(int i = 0; i < ls.size(); ++i)
    for(int j = 0; j < 2; ++j) ps.push_back(ls[i][j]);

  for(int i = 0; i < ps.size(); ++i) {
    vector<L> ls2;
    for(int j = 0; j < ls.size(); ++j) {
      if(ls[j][0] != ps[i] && ls[j][1] != ps[i] &&
	 !ccw(ls[j][0],ls[j][1],ps[i])) {
	ls2.push_back(L(ls[j][0],ps[i]));
	ls2.push_back(L(ls[j][1],ps[i]));
      } else {
	ls2.push_back(ls[j]);
      }
    }
    ls = ls2;
  }

  for(int i = 0; i < ls.size(); ++i) {
    int s = 0;
    for(int j = 0; j < sign.size() && s != 3; ++j) {
      P a(-1,-1), b, c;
      if(!ccw(ls[i][0],ls[i][1],sign[j][0])) {
	a = sign[j][0];
	b = ls[i][1];
	c = sign[j][1];
      } else if(!ccw(ls[i][0],ls[i][1],sign[j][1])) {
	a = sign[j][1];
	b = ls[i][1];
	c = sign[j][0];
      }
      if(a.real() == -1) continue;
      double ang = getAngle(b-a,c-a);
      if(equals(ang*2,pi)) s = 3;
      else if(ang*2 < pi) s |= 1;
      else if(ang*2 > pi) s |= 2;
    }
    if(!(s & 1)) addEdge(ls[i][0],ls[i][1]);
    if(!(s & 2)) addEdge(ls[i][1],ls[i][0]);
  }
}

void dijkstra() {
  priority_queue <vector<double> > que;
  int vis[MAX_N];
  vector<double> v(3); // cost,pos,pre-pos
  bool flag = false;
  fill(vis,vis+MAX_N,-1);
  v[0] = 0;
  v[1] = id[start];
  v[2] = -2;
  que.push(v);
  int sid = id[start];
  int gid = id[goal];
  while(que.size()) {
    v = que.top();
    que.pop();
    double cost = v[0];
    int p = (int)v[1];
    int pre = (int)v[2];
    if(vis[p] != -1) continue;
    vis[p] = pre;
    if(p == gid) {
      flag = true;
      break;
    }
    for(int i = 0; i < E[p].size(); ++i) {
      int to = E[p][i].first;
      if(vis[to] != -1) continue;
      double ncost = cost - E[p][i].second;
      v[0] = ncost;
      v[1] = to;
      v[2] = p;
      que.push(v);
    }
  }

  if(!flag) {
    cout << -1 << endl;
    return;
  }
  vector<int> path;
  for(int p = gid; vis[p] != -2; p = vis[p]) {
    path.push_back(p);
  }
  path.push_back(sid);

  reverse(path.begin(), path.end());
  for(int i = 0; i < path.size(); ++i) {
    P p = id2[path[i]];
    cout << p.real() << " " << p.imag() << endl;
  }
  cout << 0 << endl;
}

int main() {
  int N;
  while(cin >> N && N) {
    init();
    cin >> start.real() >> start.imag();
    cin >> goal.real() >> goal.imag();
    for(int i = 0; i < N; ++i) {
      P a, b;
      cin >> a.real() >> a.imag() >> b.real() >> b.imag();
      ls.push_back(L(a,b));
    }
    makeG();
    dijkstra();
  }
  return 0;
}

Measured memory_bytes: 1104