#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i < (int)(b);++i)
#define long long long
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり

int main(void) {
    while (true) {
        int N;
        cin >> N;
        if(N == 0)return 0;
        vector<int> X(N);
        vector<int> Y(N);

        vector<int> CompX;
        vector<int> CompY;
        rep(i, N)
        {
            cin >> X[i] >> Y[i];
            CompX.emplace_back(X[i]);
            CompY.emplace_back(Y[i]);
        }
        vector<int> CurtainX(4);
        vector<int> CurtainY(4);
        

        rep(i, 4)
        {
            cin >> CurtainX[i] >> CurtainY[i];
            CompX.emplace_back(CurtainX[i]);
            CompY.emplace_back(CurtainY[i]);
        }
        CompX.emplace_back(-30000);
        CompX.emplace_back(30000);
        CompY.emplace_back(-30000);
        CompY.emplace_back(30000);

        sort(CompX.begin(), CompX.end());
        sort(CompY.begin(), CompY.end());
        UNIQ(CompX);
        UNIQ(CompY);
        // unique(CompX.begin(), CompX.end());
        // unique(CompY.begin(), CompY.end()); 

        sort(CurtainX.begin(), CurtainX.end());
        sort(CurtainY.begin(), CurtainY.end());

        UNIQ(CurtainX);
        UNIQ(CurtainY);
        // unique(CurtainX.begin(), CurtainX.end());
        // unique(CurtainY.begin(), CurtainY.end()); 

        // vec.erase(unique(vec.begin(), vec.end()),vec.end())
        // cout << CompX.size() << " " << CompY.size() << endl;
        // rep(i,CompX.size())
        // {
        //     cout << CompX[i] << endl;
        // }

        int L = CompX.size();
        long boxsize = 0;
        long curtainsize = 0;
        
        rep(i, CompY.size() - 1)//縦方向
        {
            bool inbox = false;
            long u = CompY[i + 1];
            long d = CompY[i];
            rep(j, CompX.size() - 1)//横方向
            {
                long r = CompX[j + 1];
                long l = CompX[j];

                long size = (u - d) * (r - l);
                // 箱に入ったかのチェック
                if(j > 0)
                {
                    rep(r, N + 1)
                    {
                        int px = X[r];
                        int py = Y[r];
                        int qx = X[(r + 1) % N];
                        int qy = Y[(r + 1) % N];
                        if(py == qy)continue;
                        if(px != qx)continue;
                        //cout << "ko" << endl;
                        if(px == l && min(py,qy) <= d && u <= max(py,qy))
                        {
                            //cout << "ok" << endl;
                            inbox = !inbox;
                            break;
                        }
                    }
                }
                

                if(inbox)
                {
                    boxsize += size;
                    //cout << boxsize << endl;
                    if(CurtainX[0] <= l && r <= CurtainX[1] && CurtainY[0] <= d && u <= CurtainY[1])
                    {
                        curtainsize += size;
                    }
                }

            }

        }

        cout << (boxsize-curtainsize) << "\n";
    }

}


Measured memory_bytes: 3172