#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-10;
const double INF = 1e12;

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) : a(_a), b(_b), v(b - a) {}
    L(double _ax, double _ay, double _bx, double _by) : L(P(_ax, _ay), P(_bx, _by)) {}
};

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

enum { OUT, ON, IN };
int containPG(const P& p, const G& g) {
    int n = g.size();
    bool in = false;
    rep(i, n) {
        P a = here(g, i) - p, b = next(g, i) - p;
        if (a.imag() > b.imag()) swap(a, b);
        if (a.imag() <= 0 && 0 < b.imag() && cross(a, b) > 0) in = !in;
        if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
    }
    return in ? IN : OUT;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int N;
    while (cin >> N, N) {
        map<int, int> mpx, mpy;
        map<int, int> rmpx, rmpy;

        vector<int> x(N), y(N);
        rep(i, N) {
            cin >> x[i] >> y[i];
            mpx[x[i]] = 0;
            mpy[y[i]] = 0;
        }
        vector<int> a(4), b(4);
        rep(i, 4) {
            cin >> a[i] >> b[i];
            mpx[a[i]] = 0;
            mpy[b[i]] = 0;
        }

        int numx = 0;
        for (auto p : mpx) {
            mpx[p.first] = numx;
            rmpx[numx] = p.first;
            numx++;
        }

        int numy = 0;
        for (auto p : mpy) {
            mpy[p.first] = numy;
            rmpy[numy] = p.first;
            numy++;
        }

        vector<int> X(N), Y(N);
        rep(i, N) {
            X[i] = mpx[x[i]];
            Y[i] = mpy[y[i]];
        }

        vector<int> A(4), B(4);
        rep(i, 4) {
            A[i] = mpx[a[i]];
            B[i] = mpy[b[i]];
        }

        G g1;
        rep(i, N) {
            g1.emplace_back(P(1. * X[i], 1. * Y[i]));
        }

        G g2;
        rep(i, 4) {
            g2.emplace_back(P(1. * A[i], 1. * B[i]));
        }

        int ans = 0;
        rep(i, numx - 1) {
            rep(j, numy - 1) {
                P p(1. * i + 0.5, 1. * j + 0.5);
                if (containPG(p, g1) && !containPG(p, g2)) {
                    ans += (rmpx[i + 1] - rmpx[i]) * (rmpy[j + 1] - rmpy[j]);
                }
            }
        }

        cout << ans << endl;

    }

}