#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;
int dx[] = {0,-1,-1,0, 0,1, 1};
int dy[] = {0, 0, 1,1,-1,0,-1};
int gx,gy;
int n,k;
int offsetx,offsety;
const int INF = 1<<29;
struct point{
  int x,y;
  point(){}
  point(int tx,int ty):x(tx),y(ty){}
  bool operator<(const point &p)const{
	if(x != p.x)return x < p.x;
	return y < p.y;
  }
  bool operator==(const point &p)const{
	return x == p.x && y == p.y;
  }
};
vector<point> rock;
struct snake{
  vector<point> husi;
  int cost;
  snake(){
	cost = INF;
  }
  snake(vector<point> tmp){
	cost = INF;
	husi = vector<point>(tmp);
  }  
  bool operator==(const snake &right)const{
	return husi == right.husi;
  }
  bool operator<(const snake &right)const{
	return husi < right.husi;
  }
  bool check(){
	for(int i = 0;i < husi.size();i++){

	  int cnt = 0;
	  for(int d = 0;d < 7;d++){
		int nx = dx[d] + husi[i].x;
		int ny = dy[d] + husi[i].y;
		for(int j = 0;j < husi.size();j++){
		  if(i == j)continue;
		  if(nx == husi[j].x && ny == husi[j].y){
			if(abs(j - i) != 1)return false;
			cnt++;
		  }
		}
	  }
	  if((i == 0 || i == husi.size()-1)){
		if(cnt != 1)
		  return false;
	  }
	  else if(cnt != 2)return false;

	}
	return true;
  }
   
};
vector<vector<set<snake> > >  field;

void snake_print(snake sn){
  cout << "-------------------------------" << endl;
  cout << "cost =" << sn.cost << endl;
  for(int i =0 ;i < sn.husi.size();i++){
	cout << "i = " << i << " x = " << sn.husi[i].x << " y = " << sn.husi[i].y << endl;
  }
  cout << "-------------------------------" << endl;
}
vector<snake> state_change(snake tmp){

  
  vector<snake> keep;
  vector<int> b_use;
  keep.push_back(tmp);
  b_use.push_back(-2);
  for(int index = 0;index < n;index++){
	int keep_size = keep.size();
	for(int i = 1;i < 7;i++){
	  for(int j = 0;j < keep_size;j++){
		snake cur = keep[j];
		int cx = cur.husi[index].x + dx[i];
		int cy = cur.husi[index].y + dy[i];
		int flag = 0;
		for(point &p : rock){
		  if(p.x == cx && p.y == cy){
			flag = 1;
			break;
		  }
		}
		if(flag)continue;
		cur.husi[index].x = cx;
		cur.husi[index].y = cy;
		int cnt  = 0;
		for(int d = 1;d < 7;d++){
		  int nx = cx + dx[d];
		  int ny = cy + dy[d];
		  if(index == 0){
			if(nx == cur.husi[1].x && ny == cur.husi[1].y)cnt++;
		  }else if(index == n-1){
			if(nx == cur.husi[n-2].x && ny == cur.husi[n-2].y)cnt++;
		  }else{
			if(nx == cur.husi[index+1].x && ny == cur.husi[index+1].y)cnt++;
			if(nx == cur.husi[index-1].x && ny == cur.husi[index-1].y)cnt++;
		  }
		}
		if(index != 0 && index != n-1){
		  if(cnt != 2)continue;
		}
		else{
		  if(cnt != 1)continue;
		}
		if(b_use[j]+1 != index){
		  keep.emplace_back(move(cur));
		  b_use.emplace_back(index);
		}
	  }
	}
  }
  vector<snake> res;
  res.reserve(keep.size());
  for(int i = 0;i < keep.size();i++){
	if(keep[i].check())res.emplace_back(move(keep[i]));
  }

  return res;
}

void search(snake first){
  queue<snake> que;
  field[first.husi[0].y][first.husi[0].x].insert(first);
  que.push(first);  

  //int cnt = 0;

  while(!que.empty()){	
	snake cur = que.front();que.pop();
/*
	if(cnt == cur.cost) {
	  cerr << "current cost: " << cnt << endl;
	  cerr << "que size: " << que.size() << endl;
	  cnt++;
	}
*/
	if(20 - cur.cost <= max(abs(gx - cur.husi[0].x),abs(gy - cur.husi[0].y))){
	  continue;
	}

	if((cur.husi[0].x == gx && cur.husi[0].y == gy )){
	  cout << cur.cost << endl;
	  return ;
	}
	vector<snake> keep;
	keep = state_change(cur);
	
	for(int i = 0;i < keep.size();i++){
	  int cx = keep[i].husi[0].x;
	  int cy = keep[i].husi[0].y;
	  if(!field[cy][cx].count(keep[i])){		
		keep[i].cost = cur.cost+1;
		field[cy][cx].insert(keep[i]);
		que.push(keep[i]);
	  }
	}
  }
  cout << "20" << endl;
}

int main(){
  // vector<point> t(3);
  // n = 3;
  // t[0] = point(0,0);
  // t[1] = point(1,0);
  // t[2] = point(2,0);
  // snake sn = snake(t);
  // vector<snake> vec = state_change(sn);
  // for(int i = 0;i < vec.size();i++){
  // 	snake_print(vec[i]);
  // }
  // cout << vec.size() << endl;
//   vector<point> t(1);
//   n = 1;
//   t[0] = point(0,0);
// //  t[1] = point(0,1);
//   snake sn = snake(t);
//   vector<snake> vec = state_change(sn);
//   cout <<"size" << vec.size() << endl;
//   for(int i = 0;i < vec.size();i++){
//   	cout << "---------------------" << endl;
//   	for(int j = 0;j < vec[i].husi.size();j++){
//   	  cout << vec[i].husi[j].x << "   " << vec[i].husi[j].y << endl;
//   	}
//   }
//   return 0;
  while(cin >> n && n != 0){
	vector<point> tmp = vector<point>(n);
	field = vector<vector<set<snake> > >(60,vector<set<snake> >(60,set<snake>()));
	for(int i = 0;i < n;i++){
	  cin >> tmp[i].x >> tmp[i].y;
	  if(i == 0){
		offsetx = 30 - tmp[i].x;
		offsety = 30 - tmp[i].y;
	  }
	  tmp[i].x += offsetx;
	  tmp[i].y += offsety;
	}	
	cin >> k;
	rock = vector<point>(k);
	
	for(int i = 0;i < k;i++){
	  cin >> rock[i].x >> rock[i].y;
	  rock[i].x += offsetx;
	  rock[i].y += offsety;
	}

	cin >> gx >> gy;
	gx+=offsetx;
	gy+=offsety;
	
	snake first(tmp);
	first.cost = 0;
	search(first);
  }
  return 0;
}

Measured memory_bytes: 13228