#include<bits/stdc++.h>

using namespace std;

const int INF = 1 << 30;

int main()
{
  int N, x[101], y[101];
  while(cin >> N, N) {
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
    x[N] = x[0], y[N] = y[0];

    int a = -INF, b = INF, c = -INF, d = INF;
    for(int i = 0; i < 4; i++) {
      int u, t;
      cin >> u >> t;
      a = max(a, u), b = min(b, u);
      c = max(c, t), d = min(d, t);
    }
    long long ret1 = 0, ret2 = 0;
    for(int i = 0; i < N; i++) {
      if(y[i] == y[i + 1]) {
        ret2 += 1LL * y[i] * (x[i] - x[i + 1]);
        ret1 += 1LL * max(d, min(c, y[i])) * (max(b, min(a, x[i])) - max(b, min(a, x[i + 1])));
      }
    }
    cout << ret2 - ret1 << endl;
  }
}