#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int N;
vector<int> a(4),b(4);
vector<int> a2(4),b2(4);
int l,r,u,d;

using P = pair<int,int>;
using PP = pair<P,P>;

// 0.5 2.5
// l : 1 r : 3 , d : 0 , u : 2
inline bool inCaten(double x,double y){
    if(d<= x and x<=u and l<= y and y<=r) return true;
    else return false;
}

void solve(){
    vector<int> x(N),y(N);
    for(int i=0;i<N;i++) cin >> x[i] >> y[i];
    for(int i=0;i<4;i++) cin >> a[i] >> b[i];

    set<int> xset,yset;
    for(int i=0;i<N;i++){
        xset.insert(x[i]); yset.insert(y[i]);
    }
    for(int i=0;i<4;i++){
        xset.insert(a[i]); yset.insert(b[i]);
    }

    map<int,int> X,rX,Y,rY;
    int cnt = 0;
    for(auto xx : xset){
        X[xx] = cnt;
        rX[cnt] = xx;
        cnt++;
    }
    cnt = 0;
    for(auto yy : yset){
        Y[yy] = cnt;
        rY[cnt] = yy;
        cnt++;
    }

    // 座標変換
    vector<int> x2(N),y2(N);
    for(int i=0;i<N;i++){
        x2[i] = X[x[i]];
        y2[i] = Y[y[i]];
    }
    for(int i=0;i<4;i++){
        a2[i] = X[a[i]];
        b2[i] = Y[b[i]];
    }

    // カーテンの座標 
    l = 200000; r = 0;
    d = 200000; u = 0;
    for(int i=0;i<4;i++) d = min(d,a2[i]);
    for(int i=0;i<4;i++) u = max(u,a2[i]);
    for(int i=0;i<4;i++) l = min(l,b2[i]);
    for(int i=0;i<4;i++) r = max(r,b2[i]);

    
    int H = xset.size();
    int W = yset.size();

    vector<vector<bool>> table(H+10,vector<bool>(W+10,false));
    map<PP,bool> edge;

    for(int i=0;i<N;i++){
        int nxt = (i+1) % N;

        int myx = x2[i];
        int myy = y2[i];
        int nxtx = x2[nxt];
        int nxty = y2[nxt];

        //edge[PP(P(myx,myy),P(nxtx,nxty))] = true;
        //edge[PP(P(nxtx,nxty),P(myx,myy))] = true;
    
        // TODO : FIX
        if(myx == nxtx){
            for(int yy = min(myy,nxty); yy <= max(myy,nxty); yy++){
                if(yy+1 <= max(myy,nxty)){
                    edge[PP(P(myx,yy),P(myx,yy+1))] = true;
                    edge[PP(P(myx,yy+1),P(myx,yy))] = true;
                }
                table[myx][yy] = true;
            }
        }else{
            for(int xx = min(myx,nxtx); xx <= max(myx,nxtx); xx++){
                if(xx+1 <= max(myx,nxtx)){
                    edge[PP(P(xx,myy),P(xx+1,myy))] = true;
                    edge[PP(P(xx+1,myy),P(xx,myy))] = true;
                }
                table[xx][myy] = true;
            }
        }
    }
/*
    cerr << "H " << H << endl;
    cerr << "W " << W << endl;
    cerr << "l " << l << endl;
    cerr << "r " << r << endl;
    cerr << "d " << d << endl;
    cerr << "u " << u << endl;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cerr << table[i][j];
        }
        cerr << endl;
    }

    if(edge[PP(P(0,0),P(0,1))]){
        cerr << "POI" << endl;
    }else{
        cerr << "HA" << endl;
    }
*/

    long long ans = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            double nowx = (i + i + 1) / 2.0;
            double nowy = (j + j + 1) / 2.0;
            if(inCaten(nowx,nowy)){
                //cerr << nowx << " " << nowy << " " << "CARTEN" << endl;
                continue;
            }
            int cnt1=0,cnt2=0;
            if(!rX.count(i+1) or !rY.count(j+1)) continue;
            for(int k=i;k>=0;k--){
                if(edge[PP(P(k,j),P(k,j+1))]){
                    cnt1++;
                }
                /*
                if(table[k][j] and table[k][j+1]){
                    cerr << "cnt1 " << "(" << k << "," << j << ")" << " "  << "(" << k << "," << j+1 << ")" << endl;
                    cnt1++;
                }
                */
            }
            for(int k=i+1;k<H;k++){
                if(edge[PP(P(k,j),P(k,j+1))]){
                    cnt2++;
                }
                /*
                if(table[k][j] and table[k][j+1]){
                    cerr << "cnt2 " << "(" << k << "," << j << ")" << " "  << "(" << k << "," << j+1 << ")" << endl;
                    cnt2++;
                }
                */
            }
            if(cnt1%2==1 and cnt2%2==1){
                int dx = rX[i+1] - rX[i];
                int dy = rY[j+1] - rY[j];
                ans += dx * dy;
                //cerr << nowx << " " << nowy << " " << "OK" << endl;
            }
            else{
                //cerr << nowx << " " << nowy << " " << "NO" << cnt1 << " " << cnt2 << endl;
            }
        }
    }
    cout << ans << endl;
}

int main(){
    while(1){
        cin >> N;
        if(N==0) break;
        solve();
    }
}



Measured memory_bytes: 3072