#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
D eps=1e-9;
D dot(P a,P b){return real(conj(a)*b);}
D cro(P a,P b){return imag(conj(a)*b);}
int ccw(P a,P b,P c){
	if(cro(b-a,c-a)>eps) return 1;
	if(cro(b-a,c-a)<-eps) return -1;
	return 0;
}
P perp(L l,P p){
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
P refl(L l,P p){
	return p+2.0*(perp(l,p)-p);
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		P s;
		{
			int x,y;
			cin>>x>>y;
			s=P(x,y);
		}
		Pol pol_;
		rep(i,N){
			int x,y;
			cin>>x>>y;
			pol_.pb(P(x,y));
		}
		int o[8]={};
		rep(i,N) o[i]=i;
		int ans=0;
		do{
			Pol pol=pol_;
			P ri=pol[o[0]],le=pol[(o[0]+1)%N];
			bool ok=1;
			rep(i,N){
				P a=pol[o[i]],b=pol[(o[i]+1)%N];
				if(i%2) swap(a,b);
				if(ccw(s,ri,a)==1) ri=a;
				if(ccw(s,le,b)==-1) le=b;
				if(ccw(s,ri,le)!=1){
					ok=0;
					break;
				}
				L l=L(pol[o[i]],pol[(o[i]+1)%N]);
				rep(j,N) pol[j]=refl(l,pol[j]);
			}
			if(ok) ans++;
		}while(next_permutation(o,o+N));
		cout<<ans<<endl;
	}
}