#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

typedef complex<ll> P;
typedef pair<P,P> S;
typedef pair<double,P> State;

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

ll dot(P a,P b){ return real(b*conj(a)); }
ll cross(P a,P b){ return imag(b*conj(a)); }
int state(S s,P p){
  P a=s.first,b=s.second;
  if(a==p||b==p)return 0;
  if(cross(a-p,b-p)!=0)return 1;
  if(dot(a-p,b-p)>0)return 1;
  return -1;
}

bool check(P si,P ti,const vector<S> &v,const vector<S> &E,const vector<P> &C){
  for(int i=0;i<(int)C.size();i++)
    if( state( S(si,ti) , C[i] ) == -1 ) return false;

  for(int i=0;i<(int)v.size();i++){
    if(state(v[i],si)==1||state(v[i],ti)==1)continue;
    bool res=true;
    for(int j=0;j<(int)E.size();j++){
      if( state(S(si,ti),E[j].first ) !=-1 && state(S(si,ti),E[j].second) !=-1)continue;
      P ve;
      if( state(S(si,ti),E[j].first ) ==-1)ve=E[j].first-E[j].second;
      if( state(S(si,ti),E[j].second) ==-1)ve=E[j].second-E[j].first;
      if( dot(ti-si,ve) <= 0 ){
        res=false;
      }
    }
    if(res)return true;
  }


  
  return false;
}

P input(){
  ll x,y;
  cin>>x>>y;
  return P(x,y);
}

int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    vector<S> A,B,E;
    P si=input();
    P ti=input();
    for(int i=0;i<n;i++){
      S s;
      s.first=input();
      s.second=input();
      A.push_back(s);
    }
    for(int i=0;i<n;i++){
      int fc=0,sc=0;
      int fk=0,sk=0;
      for(int j=0;j<n;j++){
        if(i==j)continue;
        if(state(A[j],A[i].first)<=0)fc++;
        if(state(A[j],A[i].first)==-1)fk++;
        if(state(A[j],A[i].second)<=0)sc++;
        if(state(A[j],A[i].second)==-1)sk++;
      }
      bool flg=false;
      if(fc==0&&sk>0)flg=true;
      if(sc==0&&fk>0)flg=true;
      if(flg)E.push_back(A[i]);
      else B.push_back(A[i]);
    }
                               
    vector<P> C;
    for(int i=0;i<(int)B.size();i++){
      C.push_back(B[i].first);
      C.push_back(B[i].second);
    }
    //    C.push_back(si);
    //    C.push_back(ti);
    sort(C.begin(),C.end());
    C.erase(unique(C.begin(),C.end()),C.end());
    assert( *lower_bound(C.begin(),C.end(), si ) == si );
    assert( *lower_bound(C.begin(),C.end(), ti ) == ti );
    
    priority_queue< State ,vector<State> , greater<State> > Q;
    map<P,double> d;
    map<P,P> prev;
    
    for(int i=0;i<(int)C.size();i++){
      d[C[i]]=1e9;
      prev[C[i]]=P(-1,-1);
    }
    
    Q.push( State(0,si) );
    d[si]=0;
    while(!Q.empty()){
      State s=Q.top();
      Q.pop();
      P p=s.second;
      double cost=s.first;
      if(d[p]<cost)continue;
      
      for(int j=0;j<(int)C.size();j++){
        P to=C[j];
        if(p==to)continue;
        if(!check(p,to,B,E,C))continue;
        double ncost=cost;
        double dx=to.real()-p.real();
        double dy=to.imag()-p.imag();
        
        ncost+= sqrt(dx*dx+dy*dy);
        
        if(d[to]>ncost){
          d[to]=ncost;
          prev[to]=p;
          Q.push( State(ncost,to) );
        }
      }
    }

    if(d[ti]==1e9){
      cout<<-1<<endl;
    }else{
      vector<P> ans;
      P cur=ti;
      while(1){
        ans.push_back(cur);
        if(cur==si)break;
        cur=prev[cur];
        assert(cur!=P(-1,-1));
      }
      reverse(ans.begin(),ans.end());
      for(int i=0;i<(int)ans.size();i++){
        if(i>0&&ans[i]==ans[i-1])continue;
        cout<<ans[i].real()<<' '<<ans[i].imag()<<endl;
      }
      cout<<0<<endl;
    }
    
    //    printf("%.10f\n",d[ti]);
  }
  return 0;
}

Measured memory_bytes: 3148