#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};
typedef Point Vector;


struct Line{
	Point p[2];
	Line(Point p1,Point p2){
		p[0] = p1;
		p[1] = p2;
	}
	Line(){

	}
};

typedef vector<Point> Polygon;


int N;
int table[8];
Point start,point[10][10];

double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -1;
static const int ON_SEGMENT = 0;

int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}

//lineに対してpointと線対称な位置にある点を返却する関数
Point getReflectionPoint(Line line,Point point){

	double x1,x2,xp,y1,y2,yp,slope,ansx,ansy;
	bool X_FLG = false,Y_FLG = false;

	x1 = line.p[0].x;
	y1 = line.p[0].y;

	x2 = line.p[1].x;
	y2 = line.p[1].y;

	xp = point.x;
	yp = point.y;

	if(y1 == y2){
		X_FLG = true;
	}else if(x1 == x2){
		Y_FLG = true;
	}else{
		slope = (y2-y1)/(x2-x1);
	}

	if(X_FLG){

		ansx = xp,ansy=y1;
		return Point(2*ansx-xp,2*ansy-yp);

	}else if(Y_FLG){
		ansx = x1,ansy = yp;
		return Point(2*ansx-xp,2*ansy-yp);

	}else{

		ansx = (yp*(x2-x1)*(y2-y1)+xp*(x2-x1)*(x2-x1)-y1*(y2-y1)*(x2-x1)+x1*(y2-y1)*(y2-y1))/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
		ansy = ((x1-x2)*ansx+yp*(y2-y1)+xp*(x2-x1))/(y2-y1);
		return Point(2*ansx-xp,2*ansy-yp);
	}
}

bool is_OK(){

	for(int i = 0; i < N-1; i++){

		Line base_line;

		base_line.p[0] = point[i][table[i]];
		base_line.p[1] = point[i][(table[i]+1)%N];

		for(int k = 0; k < N; k++){

			point[i+1][k] = getReflectionPoint(base_line,point[i][k]);
		}
	}

	Vector L = point[0][table[0]]-start;
	Vector R = point[0][(table[0]+1)%N]-start;

	for(int i = 1; i < N; i++){

		Vector next_L = point[i][table[i]]-start;
		Vector next_R = point[i][(table[i]+1)%N]-start;

		if(cross(next_L,next_R) < 0){

			swap(next_L,next_R);
		}

		if(cross(L,next_L) > 0){

			L = next_L;
		}

		if(cross(next_R,R) > 0){

			R = next_R;
		}

		if(cross(L,R) < EPS){

			return false;
		}
	}

	return true;
}

void func(){

	scanf("%lf %lf",&start.x,&start.y);

	for(int i = 0; i < N; i++){

		scanf("%lf %lf",&point[0][i].x,&point[0][i].y);
	}

	for(int i = 0; i < N; i++){

		table[i] = i;
	}

	int ans = 0;

	do{

		if(is_OK()){

			ans++;
		}

	}while(next_permutation(table,table+N));

	printf("%d\n",ans);
}

int main(){

	while(true){

		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3160