#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

#define int long long

#define INF ((int)1e17)
#define MAX 400
#define x first
#define y second

signed main(){
  
  while(true){
    int N;
    pair<int,int>p[4] = {};
    vector<int> xc, yc;
    vector<pair<int,int> > c;
    
    int area = 0;
	vector<vector<int>> field(MAX, vector<int>(MAX,0)), field2(MAX, vector<int>(MAX,0));
    //  int field[MAX][MAX] = {}, field2[MAX][MAX] = {};

	
    cin>>N;
    
    if(N == 0) break;
    
    c.resize(N);
    
    
    xc.push_back(INF);
    yc.push_back(INF);
    
    xc.push_back(-INF);
    yc.push_back(-INF);
    
    for(int i = 0;  i < N; i++){
      cin>>c[i].x>>c[i].y;
      
      xc.push_back(c[i].x);
      yc.push_back(c[i].y);
    }
    
    for(int i = 0; i < 4; i++){
      cin>>p[i].x>>p[i].y;
      
      xc.push_back(p[i].x);
      yc.push_back(p[i].y);
    }
    
    
    sort(xc.begin(), xc.end());
    sort(yc.begin(), yc.end());
    
    
    xc.erase(unique(xc.begin(), xc.end()), xc.end());
    yc.erase(unique(yc.begin(), yc.end()), yc.end());
    
    for(int i = 0; i < N; i++){
      int tx = lower_bound(xc.begin(), xc.end(), c[i].x) - xc.begin();
      int ty = lower_bound(yc.begin(), yc.end(), c[i].y) - yc.begin();
      
    if(c[(i-1 + N)%N].x == c[(i)%N].x && c[(i+1 + N)%N].x == c[(i)%N].x) continue;
    if(c[(i-1 + N)%N].y == c[(i)%N].y && c[(i+1 + N)%N].y == c[(i)%N].y) continue;
    
    if(c[(i - 1 + N)%N].y > c[(i)%N].y){
      if(c[(i + 1 + N)%N].x > c[(i)%N].x){
	field[ty][tx]--;
      } else {
	field[ty][tx]--;
      }
    } else if(c[(i - 1 + N)%N].y < c[(i)%N].y){
      if(c[(i + 1 + N)%N].x > c[(i)%N].x){
	field[ty][tx]--;
      } else {
	field[ty][tx]--;
      }
    } else if(c[(i - 1 + N)%N].x > c[(i)%N].x){
      if(c[(i + 1 + N)%N].y < c[(i)%N].y){
	//	cout<<"x "<<c[(i - 1 + N)%N].x<<" "<< c[(i)%N].x<<" "<<c[(i + 1 + N)%N].x<<endl;
	//	cout<<"y "<<c[(i - 1 + N)%N].y<<" "<< c[(i)%N].y<<" "<<c[(i + 1 + N)%N].y<<endl;
	field[ty][tx]++;
      } else {
	field[ty][tx]++;
      }
    } else if (c[(i - 1 + N)%N].x < c[(i)%N].x){
      if(c[(i + 1 + N)%N].y < c[(i)%N].y){
	field[ty][tx]++;
      } else {
	field[ty][tx]++;
      }
    }
    }
    
    
    N = 4;
    for(int i = 0; i < N; i++){
      int tx = lower_bound(xc.begin(), xc.end(), p[i].x) - xc.begin();
      int ty = lower_bound(yc.begin(), yc.end(), p[i].y) - yc.begin();
    
      if(p[(i-1 + N)%N].x == p[(i)%N].x && p[(i+1 + N)%N].x == p[(i)%N].x) continue;
      if(p[(i-1 + N)%N].y == p[(i)%N].y && p[(i+1 + N)%N].y == p[(i)%N].y) continue;
      
      if(p[(i - 1 + N)%N].y > p[(i)%N].y){
	if(p[(i + 1 + N)%N].x > p[(i)%N].x){
	field2[ty][tx]--;
	} else {
	  field2[ty][tx]--;
	}
      } else if(p[(i - 1 + N)%N].y < p[(i)%N].y){
	if(p[(i + 1 + N)%N].x > p[(i)%N].x){
	  field2[ty][tx]--;
	  
	} else {
	
	  //cout<<"px "<<p[(i - 1 + N)%N].x<<" "<< p[(i)%N].x<<" "<<p[(i + 1 + N)%N].x<<endl;
	  //cout<<"py "<<p[(i - 1 + N)%N].y<<" "<< p[(i)%N].y<<" "<<p[(i + 1 + N)%N].y<<endl;
	  field2[ty][tx]--;
	}
      } else if(p[(i - 1 + N)%N].x > p[(i)%N].x){
	if(p[(i + 1 + N)%N].y < p[(i)%N].y){
	  field2[ty][tx]++;
	} else {
	  field2[ty][tx]++;
      }
      } else if (p[(i - 1 + N)%N].x < p[(i)%N].x){
	if(p[(i + 1 + N)%N].y < p[(i)%N].y){
	  field2[ty][tx]++;
	} else {
	  field2[ty][tx]++;
	}
      }
    }
    
     /*
      
      cout<<"xc.size() "<<xc.size()<<" "<<"yc.size() "<<yc.size()<<endl;
      
      cout<<endl;
      for(int i = 0; i < yc.size(); i++){
      //cout<<"\t"<<yc[yc.size()-i-1];
      for(int j = 0; j < xc.size(); j++){
      cout<<"\t"<<field[yc.size()-i-1][j];
      }cout<<endl;
  }
       */
    for(int i = 0; i < yc.size(); i++){
      for(int j = 0; j < xc.size(); j++){
	field[i][j+1] += field[i][j];
      field2[i][j+1] += field2[i][j];
      }
    }
    
    for(int i = 0; i < xc.size(); i++){
    for(int j = yc.size()-1; j >= 0; j--){
      field[j][i] += field[j+1][i];
      field2[j][i] += field2[j+1][i];
    }
  }
     /*
      cout<<endl;
      for(int i = 0; i < yc.size(); i++){
      for(int j = 0; j < xc.size(); j++){
      cout<<"\t"<<field[yc.size()-i-1][j];
      }cout<<endl;
      }
      cout<<endl;
      
      for(int i = 0; i < yc.size(); i++){
      for(int j = 0; j < xc.size(); j++){
      cout<<"\t"<<field2[yc.size()-i-1][j];
      }cout<<endl;
  }
          */
    for(int i = 2; i < yc.size()-1; i++){
      for(int j = 1; j < xc.size()-2; j++){
	if(field[i][j] && field2[i][j] == 0){
	  area += (yc[i] - yc[i-1])*(xc[j+1] - xc[j]);
	  //cout<<" "<<yc[i]<<" "<<yc[i-1]<<" "<<xc[j+1]<<" "<< xc[j]<<endl;
	  //cout<<" "<<(yc[i] - yc[i-1])<<" * "<<(xc[j+1] - xc[j])<<endl;
	}
      }
    }
    
    cout<<area<<endl;
    
  }
  return 0;
}



Measured memory_bytes: 5448