#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

typedef vector<pair<int,int> > vp;

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

bool connect(pair<int, int> a, pair<int, int> b) {
  rep (i, 6) {
    if (a.first + dy[i] != b.first) continue;
    if (a.second + dx[i] != b.second) continue;
    return true;
  }
  return false;
}

int main() {
  int n, K;
  vp sn, bl;
  pair<int, int> pos;
  while (true) {
    cin >> n;
    if (n == 0) break;
    sn.clear();
    bl.clear();
    rep (i, n) {
      cin >> pos.second >> pos.first;
      sn.push_back(pos);
    }
    cin >> K;
    rep (i, K) {
      cin >> pos.second >> pos.first;
      bl.push_back(pos);
    }
    cin >> pos.second >> pos.first;
    map<vp, int> mp;
    priority_queue<pair<int, vp>, vector<pair<int, vp> >, greater<pair<int, vp> > > que;
    que.push(make_pair(0, sn));
    int res = 20;
    //long long cnt = 0;
    mp[sn] = 0;
    while (!que.empty()) {
      //++cnt;
      pair<int, vp> now = que.top();
      que.pop();
      bool flag = true;
      rep (i, n) rep (j, i) if (now.second[i] == now.second[j]) flag = false;
      if (!flag) continue;
      if (now.second[0] == pos) {
	res = min(res, now.first);
	continue;
      }
      if (now.first >= res) continue;
      if (abs(now.second[0].first - pos.first) > 20 - now.first) continue;
      if (abs(now.second[0].second - pos.second) > 20 - now.first) continue;
      vp can = now.second;
      int mask = 0;
      for (int j = 1; j < n - 1; ++j) {
	bool ok2 = false;
	rep (k, 6) {
	  pair<int, int> p = now.second[j];
	  p.first += dy[k];
	  p.second += dx[k];
	  if (p == now.second[j - 1]) continue;
	  if (p == now.second[j + 1]) continue;
	  if (!connect(now.second[j - 1], p)) continue;
	  if (!connect(now.second[j + 1], p)) continue;
	  ok2 = true;
	  can[j].first += dy[k];
	  can[j].second += dx[k];
	  break;
	}
	if (!ok2) {
	  mask |= 1 << j;
	}
      }
      vector<pair<int, int> > canh, cant;
      rep (j, 6) {
	pair<int, int> p = now.second[0];
	p.first += dy[j];
	p.second += dx[j];
	if (p == now.second[1]) continue;
	if (!connect(p, now.second[1])) continue;
	canh.push_back(p);
      }
      rep (j, 6) {
	pair<int, int> p = now.second[n - 1];
	p.first += dy[j];
	p.second += dx[j];
	if (p == now.second[n - 2]) continue;
	if (!connect(p, now.second[n - 2])) continue;
	cant.push_back(p);
      }
      rep (i, 1 << n) {
	if (i & mask) continue;
	bool ok = true;
	rep (j, n) if ((i >> j & 3) == 3) {
	  ok = false;
	  break;
	}
	if (!ok) continue;
	vp next = now.second;
	for (int j = 1; j < n - 1; ++j) {
	  if ((i & 1 << j) == 0) continue;
	  next[j] = can[j];
	}
	if ((i & 1) && (i & (1 << (n - 1)))) {
	  rep (j, canh.size()) {
	    next[0] = canh[j];
	    rep (k, cant.size()) {
	      next[n - 1] = cant[k];
	      ok = true;
	      rep (l, n) rep (m, l - 1) {
		if (connect(next[l], next[m])) ok = false;
	      }
	      if (!ok) continue;
	      rep (l, n) rep (m, K) if (next[l] == bl[m]) ok = false;
	      if (!ok) continue;
	      if (mp.count(next) > 0 && mp[next] <= now.first + 1) continue;
	      mp[next] = now.first + 1;
	      que.push(make_pair(now.first + 1, next));
	    }
	  }
	}
	else if (i & 1) {
	  rep (j, canh.size()) {
       	    next[0] = canh[j];
	    ok = true;
	    rep (l, n) rep (m, l - 1) {
	      if (connect(next[l], next[m])) ok = false;
	    }
	    if (!ok) continue;
	    rep (l, n) rep (m, K) if (next[l] == bl[m]) ok = false;
	    if (!ok) continue;
	    if (mp.count(next) > 0 && mp[next] <= now.first + 1) continue;
	    mp[next] = now.first + 1;
	    que.push(make_pair(now.first + 1, next));
	  }
	}
	else if (i & (1 << (n - 1))) {
	  rep (k, cant.size()) {
	    next[n - 1] = cant[k];
	    ok = true;
	    rep (l, n) rep (m, l - 1) {
	      if (connect(next[l], next[m])) ok = false;
	    }
	    if (!ok) continue;
	    rep (l, n) rep (m, K) if (next[l] == bl[m]) ok = false;
	    if (!ok) continue;
	    if (mp.count(next) > 0 && mp[next] <= now.first + 1) continue;
	    mp[next] = now.first + 1;
	    que.push(make_pair(now.first + 1, next));
	  }
	}
	else {
	  ok = true;
	  rep (l, n) rep (m, l - 1) {
	    if (connect(next[l], next[m])) ok = false;
	  }
	  if (!ok) continue;
	  rep (l, n) rep (m, K) if (next[l] == bl[m]) ok = false;
	  if (!ok) continue;
	  if (mp.count(next) > 0 && mp[next] <= now.first + 1) continue;
	  mp[next] = now.first + 1;
	  que.push(make_pair(now.first + 1, next));
	}
      }
    }
    //cout << cnt << " ";
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 15728