#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <utility>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
P unit(const P &p){
    return p/abs(p);
}
P rotate(const P &p, double rad){
    return p *P(cos(rad), sin(rad));
}

bool intersectLL(const L& a, const L& b){
    return ( abs(cross(a[1]-a[0], b[1]-b[0])) > EPS ) ||
                                ( abs(cross(a[1]-a[0], b[0]-a[0])) < EPS );
}
bool intersectLS(const L& l, const L& s){
    return cross(l[1]-l[0], s[0]-l[0])*
        cross(l[1]-l[0], s[1]-l[0]) < EPS;
}
bool intersectLP(const L& l, const P& p){
    return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L& a, const L& b){
    return ( ccw(a[0],a[1],b[0]) *ccw(a[0],a[1],b[1]) <= 0 ) &&
        ( ccw(b[0],b[1],a[0]) *ccw(b[0],b[1],a[1]) <= 0 );
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}

P projection(const L& l, const P& p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}
P reflection(const L& l, const P& p) {
    return p + 2.0*(projection(l, p) -p);
}
L reflection(const L& l, const L& m) {
    return L(reflection(l, m[0]), reflection(l, m[1]));
}

double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
double distanceLS(const L &l, const L &s) {
    if (intersectLS(l, s)) return 0;
    return min( distanceLP(l, s[0]), distanceLP(l, s[1]) );
}
double distanceSP(const L &s, const P &p) {
    if(dot(s[1]-s[0], p-s[0]) < EPS) return abs(p-s[0]);
    if(dot(s[0]-s[1], p-s[1]) < EPS) return abs(p-s[1]);
    return distanceLP(s, p);
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        
        double sx,sy;
        cin >> sx >> sy;
        P s(sx, sy);

        VP p(n);
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y;
            p[i] = P(x, y);
        }

        vector<L> l(n);
        for(int i=0; i<n; i++){
            l[i] = L(p[i], p[(i+1)%n]);
        }
        sort(l.begin(), l.end());
        int ans = 0;
        do{
            vector<L> w = l;
            for(int i=0; i<n; i++){
                for(int j=i+1; j<n; j++){
                    w[j] = reflection(w[i], w[j]);
                }
                //cout << w[i][0] << " " << w[i][1] << endl;
            }
            VP cond;
            for(int i=0; i<n; i++){
                for(int d=0; d<2; d++){
                    cond.push_back(w[i][d] +unit(w[i][1-d]-w[i][d])*1e-6);
                }
            }
            for(P pp: cond){
                L ray(s, pp);
                vector<pair<P, int> > cp;
                cp.emplace_back(s, 0);
                for(int i=0; i<n; i++){
                    if(!isParallel(ray, w[i]) && intersectLS(ray, w[i])){
                        cp.emplace_back(crosspointLL(ray, w[i]), i+1);
                    }else{
                        break;
                    }
                }
                sort(cp.begin(), cp.end());
                if(cp[0].second != 0){
                reverse(cp.begin(), cp.end());
                }
                //cout << cp.size() << endl;
                bool ok = (int)cp.size() == n+1;
                for(int i=0; i<n+1; i++){
                    if(cp[i].second != i){
                        ok = false;
                    }
                }
                if(ok){
                    ans++;
                    break;
                }
            }
        }while(next_permutation(l.begin(), l.end()));
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3228