#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define EPS (1e-10)
#define eq(a, b) (fabs((a)-(b)) < EPS)
#define lt(a, b) ((a) - (b) < -EPS)
#define le(a, b) (eq(a, b) || lt(a, b))

struct Point {
  double x, y;
  Point(double x = 0.0, double y = 0.0):x(x), y(y){}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(x * a, y * a); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point& p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point& p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;

double norm(Vector v) { return v.x*v.x + v.y*v.y; }
double abs(Vector v) { return sqrt(norm(v)); }
double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; }
double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; }

#define COUNTER_CLOCKWISE +1
#define CLOCKWISE         -1
#define ONLINE_BACK       +2
#define ONLINE_FRONT      -2
#define ON_SEGMENT        +0
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
  if(cross(a, b) < -EPS) return CLOCKWISE;
  if(dot(a, b) < -EPS) return ONLINE_BACK;
  if(a.norm() < b.norm()) return ONLINE_FRONT;
  return ON_SEGMENT;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
	  ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

double getDistance(Point a, Point b) { return abs(a - b); }
double getAngle(Point a, Point b, Point c) {
  Vector v = b - a, w = c - b;
  double alpha = atan2(v.y, v.x), beta = atan2(w.y, w.x);
  if(alpha > beta) swap(alpha, beta);
  double theta = (beta - alpha) * 180 / M_PI;
  return min(theta, 360 - theta);
}

struct Segment {
  Point s, t;
  Segment(Point s = Point(), Point t = Point()):s(s), t(t){}
};
typedef Segment Line;

bool intersect(Segment s1, Segment s2) {
  return intersect(s1.s, s1.t, s2.s, s2.t);
}

Point getCrossPoint(Segment s1, Segment s2) {
  assert(intersect(s1, s2));
  Vector base = s2.t - s2.s;
  double d1 = abs(cross(base, s1.s - s2.s));
  double d2 = abs(cross(base, s1.t - s2.s));
  //cout<<base.x<<" "<<base.y<<" "<<(s1.s-s2.s).x<<" "<<(s1.s-s2.s).y<<endl;
  //cout<<d1<<" "<<d2<<endl;
  //assert(!eq(d1+d2, 0));
  if(eq(d1+d2, 0)) return Point(0, 0);
  double t = d1 / (d1 + d2);
  return s1.s + (s1.t - s1.s) * t;
}
Point getCrossPointLL(Line l1, Line l2) {
  Vector v1 = l1.t - l1.s, v2 = l2.t - l2.s;
  double d = cross(v2, v1);
  if(abs(d) < EPS) return l2.s;
  return l1.s + v1 * cross(v2, l2.t - l1.s) * (1.0 / d);
}

bool mergeIfAble(Segment &s1, Segment s2) {
  if(abs(cross(s1.t - s1.s, s2.t - s2.s)) > EPS) return false;
  if(ccw(s1.s, s2.s, s1.t) == COUNTER_CLOCKWISE ||
     ccw(s1.s, s2.s, s1.t) == CLOCKWISE) return false;
  if(ccw(s1.s, s1.t, s2.s) == ONLINE_FRONT ||
     ccw(s2.s, s2.t, s1.s) == ONLINE_FRONT) return false;
  s1 = Segment(min(s1.s, s2.s), max(s1.t, s2.t));
  return true;
}
void mergeSegments(vector<Segment>& segs) {
  for(int i = 0; i < (int)segs.size(); i++) {
    if(segs[i].t < segs[i].s) swap(segs[i].s, segs[i].t);
  }
  for(int i = 0; i < (int)segs.size(); i++) {
    for(int j = i+1; j < (int)segs.size(); j++) {
      if(mergeIfAble(segs[i], segs[j])) {
	segs[j--] = segs.back(), segs.pop_back();
      }
    }
  }
}

struct edge {
  int to;
  double cost;
  edge(){}
  edge(int to, double cost):to(to), cost(cost){}

  bool operator < (const edge& e) const {
    return lt(cost, e.cost);
  }
};
typedef vector< vector<edge> > Graph;

Graph segmentArrangement(vector<Segment>& segs, vector<Point>& ps) {
  for(int i = 0; i < (int)segs.size(); i++) {
    ps.push_back(segs[i].s);
    ps.push_back(segs[i].t);
    for(int j = i+1; j < (int)segs.size(); j++) {
      if(intersect(segs[i], segs[j])) {
	ps.push_back(getCrossPoint(segs[i], segs[j]));
      }
    }
  }
  sort(ps.begin(), ps.end());
  ps.erase(unique(ps.begin(), ps.end()), ps.end());
  Graph graph(ps.size());
  for(int i = 0; i < (int)segs.size(); i++) {
    vector< pair<double, int> > ls;
    for(int j = 0; j < (int)ps.size(); j++) {
      if(ccw(segs[i].s, segs[i].t, ps[j]) == ON_SEGMENT) {
	ls.emplace_back(getDistance(segs[i].s, ps[j]), j);
      }
    }
    sort(ls.begin(), ls.end());
    for(int j = 0; j+1 < (int)ls.size(); j++) {
      int u = ls[j].second, v = ls[j+1].second;
      //cout<<u<<" "<<v<<endl;
      graph[u].emplace_back(v, getDistance(ps[u], ps[v]));
      graph[v].emplace_back(u, getDistance(ps[u], ps[v]));
    }
  }
  return graph;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  //cout << fixed << setprecision(12);

  int n;
  while(cin >> n, n) {
    Point s, g;
    cin >> s.x >> s.y;
    cin >> g.x >> g.y;
    vector<Segment> segs;
    rep(i, n) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      segs.push_back(Segment(Point(a, b), Point(c, d)));
    }

    vector<Segment> streets;
    vector<Segment> signs;
    rep(i, n) {
      bool f = false, g = false;
      rep(j, n) {
	if(i == j) continue;
	if(ccw(segs[j].s, segs[j].t, segs[i].s) == ON_SEGMENT) f = true;
	if(ccw(segs[j].s, segs[j].t, segs[i].t) == ON_SEGMENT) g = true;
      }
      if(f&&g) streets.push_back(segs[i]);
      else if(f||g) signs.push_back(segs[i]);
    }

    auto check = [&](Point from, Point to) ->bool {
      Segment seg(from, to);
      rep(i, signs.size()) {
	if(intersect(seg, signs[i])) {
	  Point a = from;
	  Point b = ccw(seg.s, seg.t, signs[i].s) == ON_SEGMENT ? signs[i].s : signs[i].t;
	  Point c = b == signs[i].s ? signs[i].t : signs[i].s;
	  double angle = getAngle(a, b, c);
	  //cout<<angle<<endl;
	  if(!lt(angle, 90)) return false;
	}
      }
      return true;
    };

    auto dijkstra = [&]() ->double {
      vector<Point> ps;
      Graph graph = segmentArrangement(streets, ps);
      //rep(i, ps.size()) cout << ps[i].x<<" "<<ps[i].y<<endl;
      int start = -1, goal = -1;
      rep(i, ps.size()) {
	if(s == ps[i]) start = i;
	if(g == ps[i]) goal = i;
      }
      assert(~start && ~goal);
      vector<double> mincost(ps.size(), 1e18);
      vint prevv(ps.size(), -1);
      mincost[goal] = 0;
      using Pd = pair<double, int>;
      priority_queue<Pd, vector<Pd>, greater<Pd> > que;
      que.emplace(0, goal);
      while(!que.empty()) {
	auto p = que.top(); que.pop();
	int v = p.second;
	if(v == start) {
	  for(int i = start; i != -1; i = prevv[i]) {
	    cout << ps[i].x << " " << ps[i].y << endl;
	  }
	  cout << 0 << endl;
	  return mincost[v];
	}
	if(lt(mincost[v], p.first)) continue;
	for(auto e : graph[v]) {
	  //cout<<v<<" "<<e.to<<" "<<ps[v].x<<" "<<ps[v].y<<" "<<ps[e.to].x<<" "<<ps[e.to].y<<endl;
	  if(!check(ps[v], ps[e.to])) continue;
	  if(lt(mincost[v]+e.cost, mincost[e.to])) {
	    //cout<<v<<" "<<e.to<<" "<<ps[v].x<<" "<<ps[v].y<<" "<<ps[e.to].x<<" "<<ps[e.to].y<<endl;
	    mincost[e.to] = mincost[v]+e.cost;
	    prevv[e.to] = v;
	    que.emplace(mincost[e.to], e.to);
	  }
	}
      }
      return -1.0;
    };

    double dist = dijkstra();
    //cout<<s.x<<" "<<s.y<<" "<<g.x<<" "<<g.y<<" "<<dist<<endl;
    if(dist == -1.0) cout << -1 << endl;
  }

  return 0;
}



Measured memory_bytes: 3336