import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

struct Point {
    int x, y;
}

void main() {
    while (true) {
        int N; readf("%d\n", &N);
        if (N == 0) break;
        auto P = new Point[N];
        auto A = new Point[4];
        foreach (ref p; P) { readf("%d %d\n", &p.x, &p.y); }
        foreach (ref p; A) { readf("%d %d\n", &p.x, &p.y); }
        auto X = (P.dup ~ A.dup).map!"a.x".array;
        auto Y = (P.dup ~ A.dup).map!"a.y".array;

        X = X.sort.uniq.array;
        Y = Y.sort.uniq.array;
        int[int] mX, mY;
        foreach (int i, x; X) mX[x] = i;
        foreach (int i, y; Y) mY[y] = i;
        auto H = Y.size;
        auto W = X.size;

        int ax = int.max, ay = int.max, bx = int.min, by = int.min;
        foreach (a; A) {
            ax = min(ax, a.x);
            ay = min(ay, a.y);
            bx = max(bx, a.x);
            by = max(by, a.y);
        }
        ax = mX[ax]; ay = mY[ay];
        bx = mX[bx]; by = mY[by];

        int area(int i, int j) {
            if (i + 1 == H || j + 1 == W) return 0;
            int sy = Y[i], ty = Y[i + 1];
            int sx = X[j], tx = X[j + 1];
            int dy = ty - sy;
            int dx = tx - sx;
            return dy * dx;
        }

        auto D = new int[][](H, W);
        int n = P.size;
        for (int i = 0; i < n; i++) {
            auto p = P[i], q = P[(i + 1) % n];
            auto s = Point(mX[p.x], mY[p.y]);
            auto t = Point(mX[q.x], mY[q.y]);
            if (s.y == t.y) continue;
            assert(s.x == t.x);
            int dy = (t.y - s.y) / abs(t.y - s.y);
            do {
                int y = s.y + (dy == -1 ? -1 : 0);
                D[y][s.x] = (dy == -1 ? 1 : -1);
                s.y += dy;
            } while (s != t);
        }
        long ans = 0;
        for (int i = 0; i < H; i++) {
            int d = 0;
            for (int j = 0; j < W; j++) {
                d += D[i][j];
                assert(0 <= d && d <= 1);
                if (! (ax <= j && j < bx && ay <= i && i < by) ) {
                    ans += d * area(i, j);
                }
            }
            assert(d == 0);
        }
        writeln(ans);

    }

}