#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

void compress(vi &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

int idx(int i,vector<int> &c){
    return lower_bound(all(c),i)-c.begin();
}

int main(void) {
    int i,j;
    int n;
    while(cin >> n, n){
        int m = n + 4;
        vi xx(m), yy(m);
        vi x(n+1),y(n+1);
        rep(i,n) cin >> x[i] >> y[i], xx[i] = x[i], yy[i] = y[i];
        vi rx(4),ry(4);
        rep(i,4) cin >> rx[i] >> ry[i], xx[n+i] = rx[i], yy[n+i] = ry[i];

        xx.push_back(INF);xx.push_back(-INF);
        yy.push_back(INF);yy.push_back(-INF);
        compress(xx);compress(yy);

        x[n] = x[0], y[n] = y[0];
        int a[200][200]={};

        int ax = -INF, ay = -INF;
        int ix = INF, iy = INF;

        rep(i,4){
            ax = max(ax, rx[i]);
            ay = max(ay, ry[i]);
            ix = min(ix, rx[i]);
            iy = min(iy, ry[i]);
        }

//cout << ax << " " << ay << " " << ix << " " << iy << endl;
        rep(i,n){
            if(x[i] < x[i+1]){
                loop(j,idx(x[i],xx),idx(x[i+1],xx)){
                    a[j][idx(y[i],yy)]--;
                }
            }
            if(x[i] > x[i+1]){
                loop(j,idx(x[i+1],xx),idx(x[i],xx)){
                    a[j][idx(y[i],yy)]++;
                }
            }
        }

        int ans = 0;

        rep(i,199){
            rep(j,199){
                a[i][j+1] += a[i][j];
                if(a[i][j]){
                    //cout << xx[i+1] <<" " << xx[i] << " " << yy[j+1] <<" " << yy[j] << endl;
                    if(iy <= yy[j] && yy[j+1] <= ay && ix <= xx[i] && xx[i+1] <= ax) continue;

                    ans += (xx[i+1] - xx[i])*(yy[j+1] - yy[j]);
                }
            }
        }

        cout << ans << endl;
    }
}

