#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 101;
const int wide = 20000;

int main()
{
    while(1){
        int n;
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        vector<P> cor;
        vector<P> row[wide*2+2];
        rep(i,n){
            int x,y;
            scanf("%d%d",&x,&y);
            cor.push_back(P(x,y));
        }
        vector<P> cart;
        rep(i,4){
            int a,b;
            scanf("%d%d",&a,&b);
            cart.push_back(P(a,b));
        }
        sort(cart.begin(),cart.end());
        sort(cor.begin(),cor.end());
        rep(i,n/2){
            for(int j = cor[2*i+1].second + wide - 1; j >= cor[2*i].second + wide; j--){
                row[j].push_back(P(cor[2*i].first,0));
            }
        }
        for(int j = cart[1].second + wide - 1; j >= cart[0].second + wide; j--){
            row[j].push_back(P(cart[0].first,1));
        }
        for(int j = cart[3].second + wide - 1; j >= cart[2].second + wide; j--){
            row[j].push_back(P(cart[2].first,1));
        }
        for(int j = 2*wide - 1; j >= 0; j--){
            sort(row[j].begin(),row[j].end());
        }
        int res = 0;
        for(int i = 2*wide - 1;i >= 0; i--){
            int sm = 0;
            bool hide = false;
            rep(j,row[i].size()){
                if(row[i][j].second == 1){
                    if(hide){
                        hide = false;
                    }else{
                        if(row[i][j+1].second == 1){
                            j++;
                        }else{
                            if(row[i][j+2].second == 1){
                                sm += row[i][j+3].first - row[i][j+2].first;
                                j += 3;
                            }else{
                                hide = true;
                                j += 2;
                            }
                        }
                    }
                }else{
                    if(hide){
                        if(row[i][j+1].second == 1){
                            sm += row[i][j+2].first - row[i][j+1].first;
                            hide = false;
                            j += 2;
                        }else{
                            j++;
                        }
                    }else{
                        if(row[i][j+1].second == 1){
                            if(row[i][j+2].second == 1){
                                sm += (row[i][j+3].first - row[i][j].first) - (row[i][j+2].first - row[i][j+1].first);
                                j += 3;
                            }else{
                                sm += row[i][j+1].first - row[i][j].first;
                                j += 2;
                                hide = true;
                            }
                        }else{
                            sm += row[i][j+1].first - row[i][j].first;
                            j++;
                        }
                    }
                }
            }
            res += sm;
        }
        printf("%d\n",res);
    }
	return 0;
}

Measured memory_bytes: 6764