#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;
typedef long long ll;

int N, X[104], Y[104], CXL, CYL, CXR, CYR;
int w, h;
vector<ll> vx, vy;

int compress(int n, int *p, vector<ll> &s) {
  REP(i, 0, n) s.push_back(p[i]);
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  return s.size();
}

bool isin(int x, int y) {
  return CXL <= x && x <= CXR && CYL <= y && y <= CYR;
}

bool ok(int xl, int yl, int xr, int yr) {
  if(isin(xl, yl) && isin(xr, yr)) return false;
  int x = xl + xr, y = yl + yr;
  int cx = 0, cy = 0;
  REP(i, 0, N) {
    int c = i, n = (i + 1) % N;
    int x1 = 2 * min(X[c], X[n]), x2 = 2 * max(X[c], X[n]);
    int y1 = 2 * min(Y[c], Y[n]), y2 = 2 * max(Y[c], Y[n]);
    if(y1 == y2 && y < y1 && x1 < x && x < x2) cx++;
    if(x1 == x2 && x < x1 && y1 < y && y < y2) cy++;
  }
  return cx % 2 == 1 && cy % 2 == 1;
}

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, N) cin >> X[i] >> Y[i];
    REP(i, 0, 4) cin >> X[N + i] >> Y[N + i];
    CXL = min(X[N], min(X[N + 1], min(X[N + 2], X[N + 3])));
    CYL = min(Y[N], min(Y[N + 1], min(Y[N + 2], Y[N + 3])));
    CXR = max(X[N], max(X[N + 1], max(X[N + 2], X[N + 3])));
    CYR = max(Y[N], max(Y[N + 1], max(Y[N + 2], Y[N + 3])));
    vx.clear();
    vy.clear();
    w = compress(N + 4, X, vx);
    h = compress(N + 4, Y, vy);

    ll ans = 0;
    REP(i, 0, w - 1) REP(j, 0, h - 1) if(ok(vx[i], vy[j], vx[i + 1], vy[j + 1])) ans += (vx[i + 1] - vx[i]) * (vy[j + 1] - vy[j]);
    cout << ans << endl;
  }
  return 0;
}