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

const double eps=1e-8;
int sign(double x)
{
	return (x>eps)-(x<-eps);
}
double msqrt(double x)
{
	return sign(x)>0?sqrt(x):0;
}
struct Point
{
	double x,y;
	Point()
	{
		x=0,y=0;
	}
	Point(double _x,double _y)
	{
		x=_x;
		y=_y;
	}
	Point operator+(const Point &a)	const
	{
		return Point(x+a.x,y+a.y);
	}
	Point operator-(const Point &a)	const
	{
		return Point(x-a.x,y-a.y);
	}
	Point operator*(double k)	const
	{
		return Point(x*k,y*k);
	}
	Point operator/(double k)	const
	{
		return Point(x/k,y/k);
	}
	double len()	const
	{
		return msqrt(x*x+y*y);
	}
	double len2()	const
	{
		return x*x+y*y;
	}
	Point turn90()	const
	{
		return Point(-y,x);
	}
	Point unit()	const
	{
		return *this/len();
	}
};
struct Line
{
	Point a,b;
	Line()
	{
		a=b=Point(0,0);
	}
	Line(Point _a,Point _b)
	{
		a=_a;
		b=_b;
	}
};
double dot(const Point &a,const Point &b)
{
	return a.x*b.x+a.y*b.y;
}
double det(const Point &a,const Point &b)
{
	return a.x*b.y-a.y*b.x;
}
bool isLL(const Line &l1,const Line &l2,Point &p)
{
	double s1=det(l2.b-l2.a,l1.a-l2.a);
	double s2=-det(l2.b-l2.a,l1.b-l2.a);
	if (!sign(s1+s2))	return false;
	p=(l1.a*s2+l1.b*s1)/(s1+s2);
	return true;
}
bool Onseg(const Line &l,const Point &p)
{
	return sign(det(p-l.a,l.b-l.a))==0 && sign(dot(p-l.a,p-l.b))<=0;
}
Point projection(const Line &l,const Point &p)
{
	return l.a+(l.b-l.a)*(dot(p-l.a,l.b-l.a)/(l.b-l.a).len2());
}
Point reflect(const Line &l,const Point &p)
{
	Point ha=projection(l,p);
	return (ha+(ha-p));
}
//==============template========================
const int maxn=20;
int n,sx,sy;
bool vis[maxn];
Point a[maxn];
Line b[maxn];
bool kil[maxn];
int que[maxn];
vector<vector<int> > ans;
void doit(Point delta)
{
	Point now=Point(sx,sy);
	for (int i=1;i<=n;i++)
		kil[i]=false;
	vector<int> Q;
	int pree=0;
	while ((int)Q.size() < n)
	{
		for (int i=1;i<=n;i++)
			if (sign(det(a[i]-now,delta))==0 && sign(dot(a[i]-now,delta))>0)	return;
		int pos=0;
		Point ha=Point(0,0);
		Point jd;
		for (int i=1;i<=n;i++)
		if (isLL(Line(now,now+delta),Line(a[i],a[i%n+1]),jd))
		{
			if (sign(dot(jd-now,delta))<=0)	continue;
			if (!Onseg(Line(a[i],a[i%n+1]),jd))	continue;
			if ((sign((jd-now).len()-delta.len())>0 || pree==0) && (sign(ha.len())==0 || (jd-now).len()<ha.len()))
			{
				ha=jd-now;
				pos=i;
			}
		}
		if (kil[pos])	return;
		kil[pos]=true;
		Q.push_back(pos);
		jd=now+ha;
		now=reflect(Line(a[pos],a[pos%n+1]),now);
		delta=jd-now;
		pree=pos;
	}
	ans.push_back(Q);
}
bool in(Point x,Point y,Point z)
{
	if (sign(det(x,y))>0)	swap(x,y);
	return sign(det(z,y))<=0 && sign(det(x,z))<=0;
}
bool jiao(Point &x,Point &y,Point l,Point r)
{
	if (!in(x,y,l) && !in(x,y,r))	swap(x,l),swap(y,r);
	if (!in(x,y,l) && !in(x,y,r))	return false;
	if (!in(x,y,l))	swap(l,r);
	if (in(x,y,l) && in(x,y,r))
	{
		x=l;
		y=r;
		return true;
	}
	bool xx=in(l,r,x),yy=in(l,r,y);
	if (xx && yy)
	{
		return true;
	}
	if (!xx && !yy)
	{
		x=l;
		y=r;
		return true;
	}
	if (xx && !yy)
	{
		y=l;
		return true;
	}
	x=l;
	return true;
}
void check()
{
	Point x=Point(0,0),y=Point(0,0),now=Point(sx,sy),l,r;
	for (int i=1;i<=n;i++)
	{
		now=reflect(Line(a[que[i]],a[que[i]%n+1]),now);
		x=reflect(Line(a[que[i]],a[que[i]%n+1]),x);
		y=reflect(Line(a[que[i]],a[que[i]%n+1]),y);
		l=a[que[i]]-now;
		r=a[que[i]%n+1]-now;
		x=x-now;
		y=y-now;
		if (i==1)
		{
			x=l;
			y=r;
		}	else	if (!jiao(x,y,l,r))	return;
		x=x+now;
		y=y+now;
	}
	Point ha=(x+y)/2.0;
	for (int i=n;i>=1;i--)	ha=reflect(Line(a[que[i]],a[que[i]%n+1]),ha);
	doit(ha-Point(sx,sy));
}
	
void search(int t)
{
	if (t>n)
	{
		check();
		return;
	}
	for (int i=1;i<=n;i++)
	if (!vis[i])
	{
		vis[i]=true;
		que[t]=i;
		search(t+1);
		que[t]=0;
		vis[i]=false;
	}
}

int main()
{
	while (true)
	{
		scanf("%d",&n);
		if (n==0)	break;
		scanf("%d%d",&sx,&sy);
		for (int i=1;i<=n;i++)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			a[i].x=x;
			a[i].y=y;
		}
		for (int i=1;i<=n;i++)	vis[i]=0;
		search(1);
		sort(ans.begin(),ans.end());
		ans.erase (unique (ans.begin (), ans.end ()), ans.end ());
		/*
		for (auto i:ans)
		{
			for (auto j:i)
			{
				printf("%d ",j);
			}
			printf("\n");
		}
		*/
		printf("%d\n",(int)ans.size());
		ans.clear();
	}
	return 0;
}

Measured memory_bytes: 3240