#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define X first
#define Y second

const int dx[] = {0,0,1,1,0,-1,-1}, dy[] = {0,-1,-1,0,1,1,0};

set<pii> stone;
set<vector<pii>> h;
queue<vector<pii>> que;

bool is_exist_joint(vector<pii>& joint, int x, int y) {
    REP(i, SZ(joint)) {
        if (joint[i].X == x && joint[i].Y == y) {
            return true;
        }
    }
    return false;
}

// i??????????????????????????£????????????
bool is_joined(vector<pii>& joint, int i) {
    int begin = max(0, i-1);
    int end = min(i+1, SZ(joint)-1);
    FOR(j, begin, end) {
        bool joined = false;
        FOR(d, 1, 7) {
            int sx = joint[j].X + dx[d], sy = joint[j].Y + dy[d];
            if (joint[j+1].X == sx && joint[j+1].Y == sy) {
                joined = true;
            }
        }
        if (!joined) return false;
    }
    return true;
}

bool is_dead(vector<pii>& joint) {
    REP(i, SZ(joint)) {
        // ??????????????????????????°?????¨?????????????????????
        FOR(j, i+1, SZ(joint)) {
            if (joint[i].X == joint[j].X && joint[i].Y == joint[j].Y) {
                return true;
            }
        }
        // ?????????????????????3?????\?????£??\??????????????´?????????????????????
        int adjacent = 0;
        FOR(d, 1, 7) {
            int sx = joint[i].X + dx[d], sy = joint[i].Y + dy[d];
            if (is_exist_joint(joint, sx, sy)) adjacent++;
        }
        if (adjacent >= 3) {
            return true;
        }
    }
    return false;
}

void dfs(vector<pii>& joint, int i) {
    if (i >= SZ(joint)) {
        if (!EXIST(h, joint) && !is_dead(joint)) {
            h.insert(joint);
            que.push(joint);
        }
        return;
    }

    REP(d, 7) {
        int x = joint[i].X, y = joint[i].Y;
        int sx = x + dx[d], sy = y + dy[d];
        pii to = {sx, sy};
//        if (!EXIST(stone, to) && ((x == sx && y == sy) || !is_exist_joint(joint, sx, sy))) {
        if (!EXIST(stone, to)) {
            joint[i].X = sx;
            joint[i].Y = sy;
            if (is_joined(joint, i)) {
                dfs(joint, i+2);
            }
            joint[i].X = x;
            joint[i].Y = y;
        }
    }
}

int main() {
    int joint_n;
    while (cin >> joint_n, joint_n) {
        vector<pii> joint(joint_n);
        REP(i, joint_n) {
            int x, y;
            cin >> x >> y;
            joint[i] = {x, y};
        }
        int stone_n;
        cin >> stone_n;
        stone.clear();
        REP(i, stone_n) {
            int x, y;
            cin >> x >> y;
            stone.insert({x, y});
        }
        int gx, gy;
        cin >> gx >> gy;

        int cnt = 0;
        h.clear();
        h.insert(joint);
        while (!que.empty()) que.pop();
        que.push(joint);
        vector<pii> sentry = {{1000000, 1000000}};
        que.push(sentry);
        while (!que.empty()) {
            vector<pii> joint = que.front(); que.pop();
            if (joint == sentry) {
                cnt++;
                assert(!que.empty());
                que.push(sentry);
                continue;
            }
            if (joint[0].X == gx && joint[0].Y == gy) {
//                LOG("->");
//                REP(j, SZ(joint)) {
//                    LOG(" (%d %d)", joint[j].X, joint[j].Y);
//                }
//                LOG("\n");
                break;
            }

            dfs(joint, 0);
            dfs(joint, 1);
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 37076