#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

#define UNIQUE(x) sort(x.begin(),x.end());x.erase(unique(x.begin(),x.end()),x.end()); 

/* SegmentTree(Sum) */
//0-index

struct SegTree{
  typedef int Type;
  int segn2;
  Type inf;
  vector<Type> data,s_data;
  
  SegTree(int n){
    segn2=1;
    while(segn2<n) segn2*=2;
    
    data.assign(segn2*2,0);
    s_data.assign(segn2*2,0);
  }
  
  //get sum of [a,b]
  Type query(int a,int b,int l=0,int r=-1,int k=0){
    Type ret = 0;
    
    if(r==-1) r+=segn2;
    
    if(r<a || b<l) return 0;
    
    if(a<=l && r<=b) return data[k] + s_data[k]*(r-l+1);
    
    ret += (min(r,b)-max(l,a)+1) * s_data[k];
    
    ret += query(a,b,l,(l+r)/2,k*2+1)+query(a,b,(l+r)/2+1,r,k*2+2);
    return ret;
  }
  
  //add x to [a,b]
  Type add(int a,int b,Type x,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    
    if(a<=l && r<=b){
      s_data[k]+=x;
    }else if(a<=r && l<=b){
      data[k] = add(a,b,x,l,(l+r)/2,k*2+1) + add(a,b,x,(l+r)/2+1,r,k*2+2);
    }
    
    return data[k] + s_data[k]*(r-l+1);
  }
};



void calc(int n){
  int base = 20000;
  int x[SIZE],y[SIZE], a[4],b[4];
  
  vector<pair<int,pair<int,int> > > vec;
  
  for(int i=0;i<n;i++){
    scanf("%d%d",x+i,y+i);
    x[i] += base;
    y[i] += base;

    if(i > 0 && y[i-1] == y[i]){
      vec.push_back({y[i],{min(x[i-1],x[i]),max(x[i-1],x[i])}});
    }
  }

  if(y[0] == y[n-1]){
    vec.push_back({y[0],{min(x[0],x[n-1]),max(x[0],x[n-1])}});
  }

  int min_x = INF, min_y = INF, max_x = -INF, max_y = -INF;
  
  for(int i=0;i<4;i++){
    scanf("%d%d",a+i,b+i);
    a[i]+=base; b[i]+=base;
    min_x = min(min_x, a[i]);
    min_y = min(min_y, b[i]);
    max_x = max(max_x, a[i]);
    max_y = max(max_y, b[i]);
  }

  sort(vec.begin(),vec.end());
  
  SegTree seg(base*2+10);

  int t = 0;
  ll ans = 0;
  
  for(int i=0;i<=base*2+1;i++){
    
    while(t < vec.size() && vec[t].first == i){
      if(seg.query(vec[t].second.first, vec[t].second.second-1) > 0){
        seg.add(vec[t].second.first, vec[t].second.second-1,-1);
      }else{
        seg.add(vec[t].second.first, vec[t].second.second-1,1);
      }
      t++;
    }

    if(min_y <= i && i < max_y){
      ans += seg.query(0,min_x-1) + seg.query(max_x,INF);
    }else{
      ans += seg.query(0,INF);
    }
    
  }


  printf("%lld\n",ans);
  
}


int main(){
  int n;

  while(1){
    scanf("%d",&n);
    if(n == 0) break;
    calc(n);
  }
  
  
  return 0;
}