#include<iostream>
#include<queue>
#include<vector>
#include<complex>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back
const double eps = 1e-10;

const int N = 2000;

typedef complex<double> P;

bool adj[N][N];
bool up[N][N];//up[i][j] = 1 i >=j 
bool cpyadj[N][N];
bool cpyup[N][N];

class Polygon{
public:
  vector<P> ori,newp;
  int oriid,newid;
  int cutbit;
  vector<P> inipos;
};

void outputpolygon(vector<P> &a){
  cout << "[";
  rep(i,a.size()+1)cout << a[(i+1)%a.size()]<<",";
  cout << "],"<<endl;
}


#define RIGHT 1
#define LEFT -1

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

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

bool isp(P &a,P &b,P &c){
  return abs(a-c)+abs(b-c) < abs(a-b) + eps;
}

P intersection_ll(P &a1,P &a2,P &b1,P &b2){
  P a=a2-a1,b=b2-b1;
  return a1+ a*cross(b,b1-a1)/cross(b,a);
}

int ccw(P a,P b){
  if (cross(a,b)    < -0)return RIGHT;
  else if(cross(a,b)>  0)return LEFT;
  return 2;
}

bool is_intersected_ls(P &a1,P &a2,P &b1,P &b2){
  if (isp(a1,a2,b1)||isp(a1,a2,b2)||isp(b1,b2,a1)||
      isp(b1,b2,a2))return true;
  if (cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1)<-eps &&
      cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<-eps)
    return true;
  return false;
}

//LEFT remain,RIGHT reflect
void Convex_cut(vector<P> in,P &a1,P &a2,
		vector<P> &ori,vector<P> &newp){
  int n = in.size();
  ori.clear();newp.clear();
  rep(i,n){
    P now = in[i],next=in[(i+1)%n];
    if( ccw(a1-a2,now-a2) == LEFT)ori.pb(now);
    else if( ccw(a1-a2,now-a2) == RIGHT)newp.pb(now);
    if (ccw(a1-a2,now-a2)*ccw(a1-a2,next-a2)<0){
      //ori.pb(intersection_ll(a1,a2,now,next));
      ori.pb(intersection_ll(now,next,a1,a2));
      newp.pb(intersection_ll(a1,a2,now,next));
    }
  }
}

pair<P,P> make_line(P p,P q){
  int cutpos=RIGHT;
  P tmp=(p+q);
  tmp.real()/=2;tmp.imag()/=2;
  P ret=q-tmp;
  swap(ret.real(),ret.imag());
  ret.real()*=-1;
  if ( ccw(ret,p-tmp) != cutpos)return make_pair(tmp,ret+tmp);
  return make_pair(ret+tmp,tmp);
}

bool is_in(vector<P> &in,P &a){
  int cnt=0;
  int n = in.size();
  rep(i,n){
    P cur = in[i]-a,next=in[(i+1)%n]-a;
    if (cur.imag()>next.imag())swap(cur,next);
    if (cur.imag()<0&&0<=next.imag()&&
	cross(next,cur)>= 0)cnt++;
    if (isp(in[i],in[(i+1)%n],a))return true;
  }

  if (cnt%2 == 1)return true;
  return false;
}

P reflect(P &o,P &p,P &q){
  P N=p-o,L=q-o;
  double t = abs(L);
  N/=abs(N);
  L/=abs(L);
  double prepL = dot(N,L);//theta element of vector L against N (|L|=|N|=1
  double d=2*prepL;
  P r(d*N - L);//R vector symmetric point of L
  return o+t*r;
}

int find_most_upper(int n,Polygon *in,P &p){
  int index = -1;
  rep(i,n){
    if (is_in(in[i].ori,p)){
      if (index == -1)index =i;
      else if (up[i][index])index=i;
    }
  }
  return index;
}

//a ori,b newp
bool is_intersected_polygon(vector<P> &a,vector<P> &b){
  rep(i,a.size()){
    if (is_in(b,a[i]))return true;
    rep(j,b.size()){
      if (is_intersected_ls(a[i],a[(i+1)%a.size()],
			    b[j],b[(j+1)%b.size()])){
	return true;
      }
    }
  }
  rep(j,b.size())if (is_in(a,b[j]))return true;
  return false;
}


double distance_l_p(P a,P b,P c){
  return abs( cross(b-a,c-a))/abs(b-a);
}

bool issame(P &a,P &b){
  return fabs(a.real()-b.real())<eps && fabs(a.imag()-b.imag())<eps;
}

bool have_same_line(vector<P> &in1,vector<P> &in2,P &a,P &b,bool flag){
  rep(i,in1.size()){
    rep(j,in2.size()){
      if (isp(in1[i],in1[(i+1)%in1.size()],in2[j])
	  ||isp(in1[i],in1[(i+1)%in1.size()],in2[(j+1)%in2.size()])
	  )return true;

      if ((issame(in1[i],in2[j])&&issame(in1[(i+1)%in1.size()],in2[(j+1)%in2.size()]))
	||
	(issame(in1[i],in2[(j+1)%in2.size()])&&issame(in1[(i+1)%in1.size()],in2[j]))
	)return true;
    }
  }
  return false;
}

bool vis[N];
void origami(int &n,int ini,Polygon in[N],P &a,P &b,
	     pair<P,P> *line,int querry){
  int m = n;
  vector<P> dummy;
  rep(i,N){
    in[i].newp.clear(),in[i].newid=-1;//nen no tame
  }

  rep(i,N)vis[i]=false;
  queue<int> Q;
  Q.push(ini);
  while(!Q.empty()){
    int now = Q.front();Q.pop();
    if (vis[now])continue;
    
    vis[now]=true;

    Convex_cut(in[now].ori,a,b,in[now].ori,in[now].newp);
    if (in[now].newp.size() != 0){
      in[now].oriid=now;
      in[now].newid=m++;
      in[in[now].newid].cutbit=in[now].cutbit|(1<<querry);
    }
    
    
    in[now].inipos=in[now].newp;
    for(int j=querry-1;j>=0;j--){
      if((in[now].cutbit&(1<<j)) != 0){
	rep(k,in[now].inipos.size()){
	  in[now].inipos[k]=reflect(line[j].first,line[j].second,in[now].inipos[k]);
	}
      }
    }
    
    
    rep(i,n){
      if (i == now)continue;
      if (adj[now][i]){
	if(have_same_line(in[now].inipos,in[i].inipos,a,b,false))
	  Q.push(i);
      }
      if (up[i][now]){
	if (is_intersected_polygon(in[now].newp,in[i].ori))
	  Q.push(i);
      }
    }
  }
  
  rep(i,n){
    rep(j,in[i].newp.size()){
      in[i].newp[j]=reflect(a,b,in[i].newp[j]);
    }
  }
  

  rep(i,n){
    int myori=in[i].oriid,mynew=in[i].newid;
    if (in[i].newp.size() == 0)mynew=-1;
    
    if (mynew != -1){
      up[myori][mynew]=false;
      up[mynew][myori]=true;
    }
    
    rep(j,n){
      if (i == j)continue;
      int yori=in[j].oriid,yournew=in[j].newid;
      bool tmp = up[i][j];
      //in[i].ori-in[j].ori
      up[myori][yori]=up[myori][yori];

      //in[i].ori-in[j].newp
      if (yournew != -1){
	up[myori][yournew]=false;
      }

      //in[i].newp-in[j].ori
      if (mynew != -1){
	if (is_intersected_polygon(in[i].newp,in[j].ori)){
	  up[mynew][yori]=true;
	}else {
	  up[mynew][yori]=false;
	}
      }
 
      //in[i].newp-in[j].ori
      if (mynew != -1 && yournew != -1){
	if (up[yori][myori] && is_intersected_polygon(in[i].newp,in[j].newp))
	  up[mynew][yournew]=true;
	else up[mynew][yournew]=false;
      }
    }
  }
        
    
    
  rep(i,n){
    if (in[i].newp.size() != 0){
      in[in[i].newid].ori=in[i].newp;
      in[in[i].newid].oriid=in[i].newid;
      in[i].newp.clear();
    }
  }

  n = m;

  rep(i,m){
    in[i].inipos.clear();
    in[i].inipos=in[i].ori;
    for(int j=querry;j>=0;j--){
      if((in[i].cutbit&(1<<j)) != 0){
	rep(k,in[i].inipos.size()){
	  in[i].inipos[k]=reflect(line[j].first,line[j].second,in[i].inipos[k]);
	}
      }
    }
  }

  rep(i,m){
    REP(j,i+1,m){
      if (have_same_line(in[i].inipos,in[j].inipos,a,b,true)){
	adj[i][j]=adj[j][i]=true;
      }else adj[i][j]=adj[j][i]=false;
    }
  }
}
	     
int solve(int querry){
  int n=1;
  static Polygon in[N];
  pair<P,P> line[10];
  P pos[10];
  // initialization
  rep(i,N){
    in[i].ori.clear();
    in[i].newp.clear();
    in[i].inipos.clear();
    in[i].oriid=i;
    in[i].newid=-1;
    in[i].cutbit=0;
  }
  rep(i,N)rep(j,N)adj[i][j]=false,up[i][j]=false;
  
  in[0].ori.pb(P(0,0));
  in[0].ori.pb(P(0,100));
  in[0].ori.pb(P(100,100));
  in[0].ori.pb(P(100,0));
  in[0].inipos=in[0].ori;

  rep(i,querry){
    P p,q;
    cin>>p.real()>>p.imag()>>q.real()>>q.imag();
    pos[i]=p;
    pair<P,P> tmp;
    line[i] = make_line(p,q);
  }

  rep(i,querry){
    int index = find_most_upper(n,in,pos[i]);
    if (index == -1){
    }else origami(n,index,in,line[i].first,line[i].second,
		  line,i);
  }

  
  int cnt=0;
  P hole;
  cin>>hole.real()>>hole.imag();
  rep(i,n){
    if (in[i].ori.size() && is_in(in[i].ori,hole))cnt++;
  }

  return cnt;
}

main(){
  int q;
  while(cin>>q&&q){
    cout << solve(q) << endl; 
  }
}

Measured memory_bytes: 9584