#include <cassert>// c
#include <ctime>
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>

using namespace std;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define FOR(i,l,r) for(int i=(int)l;i<(int)r;++i)
#define REP(i,n) FOR(i,0,n)
#define FORr(i,l,r) for(int i=(int)r-1;i>=(int)l;--i)
#define REPr(i,n) FORr(i,0,n)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x)  cerr << #x << " = " << (x)
#define LINE()    cerr<< " (L" << __LINE__ << ")"

template<typename T,typename U> T pmod(T x,U M){return (x%M+M)%M;}

// must template
typedef long double D;
const D INF = 1e12,EPS = 1e-8;

typedef complex<D> P;
#define X real()
#define Y imag()
istream& operator >> (istream& is,complex<D>& p){D x,y;is >> x >> y; p=P(x,y); return is;}

int sig(D a,D b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
template<typename T> bool eq(const T& a,const T& b){return sig(abs(a-b))==0;}
bool compX (const P& a,const P& b){return !eq(a.X,b.X)?sig(a.X,b.X)<0:sig(a.Y,b.Y)<0;}
namespace std{
	bool operator <  (const P& a,const P& b){return compX(a,b);}
  	bool operator == (const P& a,const P& b){return eq(a,b);}
};
// a×b
D cross(const P& a,const P& b){return imag(conj(a)*b);}
// a・b
D dot(const P& a,const P& b) {return real(conj(a)*b);}
int ccw(const P& a,P b,P c){
    b -= a; c -= a;
    if (cross(b,c) > EPS)   return +1;       // counter clockwise
    if (cross(b,c) < -EPS)   return -1;       // clockwise
    if (dot(b,c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0; //a--c--b on line (c==b,c==a)
}
// //must template

//直線・線分
struct L : public vector<P> {
	P vec() const {return this->at(1)-this->at(0);}
	L(const P &a, const P &b){push_back(a); push_back(b);}
	L(){push_back(P());push_back(P());}
};
istream& operator >> (istream& is,L& l){P s,t;is >> s >> t;l=L(s,t);return is;}

// 直線へ射影した時の点
// verified by AOJLIB
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1092212
P projection(const L &l, const P &p) {
	D t = dot(p-l[0],l.vec()) / norm(l.vec());
	return l[0] + t * l.vec();
}
//対称な点
// verified by AOJLIB
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1092214
P reflection(const L &l, const P &p) {return p + 2.0L * (projection(l, p) - p);}

//浮動小数点 pmod
D pfmod(D v,D M=2*M_PI){return fmod(fmod(v,M)+M,M);}

// 巡回区間,弧
typedef pair<D,D> Arc;//from +-> to
D arclen(const Arc& a){D res=a.second-a.first; return sig(res)>=0?res:res+2*M_PI; }
bool contain(const Arc& a, const D theta) { return sig(arclen({a.first, theta})+arclen({theta, a.second}),arclen(a))<=0;}
bool compare(const Arc& a, const Arc& b) { return sig(arclen(a),arclen(b))<0;}
Arc intersect(const Arc& a,const Arc& b){
	if(!contain(a,b.first) && !contain(b,a.first))return {0,0};
	return min<Arc>(min(a,b,compare),min<Arc>((Arc){a.first, b.second},(Arc){b.first, a.second},compare), compare);
}
Arc normalize(const Arc& a) { return min<Arc>(a,{a.second,a.first},compare);}

int N;P s;
vector<L> ls;

vector<bool> passed;
Arc lr;
int dfs(int d){
	if(sig(arclen(lr))==0)return 0;
	if(d==N)if(sig(arclen(lr))>0)return 1;
	
	int res=0;
	REP(i,N)if(!passed[i]){
		auto tmp=lr;
		Arc ar={arg(ls[i][0]-s),arg(ls[i][1]-s)};
		lr=intersect(lr,normalize(ar));
		passed[i]=true;
		REP(j,N)if(!passed[j]){
			ls[j][0]=reflection(ls[i],ls[j][0]);ls[j][1]=reflection(ls[i],ls[j][1]);
		}
		res+=dfs(d+1);
		REP(j,N)if(!passed[j]){
			ls[j][0]=reflection(ls[i],ls[j][0]);ls[j][1]=reflection(ls[i],ls[j][1]);
		}
		passed[i]=false;
		lr=tmp;
	}
	return res;
}

int main(){
	cout <<fixed <<setprecision(20);
	cerr <<fixed <<setprecision(20);

	while(true){
		cin >>N;if(N==0)break;
		cin >> s;
		vector<P> ps(N);REP(i,N)cin >>ps[i];
		ls=vector<L>(N);REP(i,N)ls[i]=L(ps[i],ps[pmod(i+1,N)]);
		lr={-4*M_PI,4*M_PI};
		passed=vector<bool>(N);
		cout << dfs(0) << endl;
	}

	return 0;
 }

Measured memory_bytes: 1264