#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

long long calcArea(const vector<P> &pts){
    long long sum = 0;
    for(int i=0;i<pts.size();i++){
        P a = pts[i];
        P b = pts[(i+1)%pts.size()];
        sum += a.first*b.second - a.second*b.first;
    }
    if(sum<0)sum = -sum;
    return sum / 2;
}


int main(){
    for(int n; cin>>n, n; ){
        long long sum = 0;
        vector<P>C;
        vector<P>W;
        set<int>X;
        set<int>Y;
        int xmin = 40000, xmax = -40000;
        int ymin = 40000, ymax = -40000;
        for(int i = 0; i < n; i++){
            int x, y;
            cin>>x>>y;
            W.push_back(P(x, y));
            X.insert(x);
            Y.insert(y);
        }
        for(int i=0;i<4;i++){
            int x, y;
            cin>>x>>y;
            C.push_back(P(x, y));            
            X.insert(x);
            Y.insert(y);
            xmin = min(xmin, x);
            xmax = max(xmax, x);
            ymin = min(ymin, y);
            ymax = max(ymax, y);
        }
        set<int>::iterator l = X.begin();
        set<int>::iterator r = X.begin();
        r++;
        for(; r != X.end(); l++, r++){
            if(xmin <= (*l) && (*r) <= xmax){
                int d = (*r) - (*l);
                set<int>::iterator b = Y.begin();
                set<int>::iterator u = Y.begin();
                u++;
                for(int on = 0;u!=Y.end();u++, b++){
                    for(int i=0;i<W.size();i++){
                        P p = W[i], q = W[(i+1)%W.size()];
                        if(p.second != q.second)continue;
                        if(p.second != (*b))continue;
                        int mx = max(p.first, q.first);
                        int mn = min(p.first, q.first);
                        if(mn <= (*l) && (*r) <= mx){
                            on = (on+1)%2;
                            break;
                        }
                    }
                    if(on){
                        if(ymin <= (*b) && (*u) <= ymax){
                            sum += d * ((*u) - (*b));
                        }
                    }
                }
            }
        }
        cout<<calcArea(W) - sum<<endl;
        
    }
    
    return 0;
}
