#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int sign(int val) {
  return val > 0 ? 1 : (val == 0 ? 0 : -1);
}

void bfs(vector<vector<bitset<4>>> &tb, pair<int,int> s) {
  int w = tb[0].size();
  int h = tb.size();
  queue<pair<int,int>> que;
  que.push(s);
  tb[s.first][s.second].set();
  while(!que.empty()) {
    int i,j;
    tie(i,j) = que.front();
    que.pop();
    int di[] = {1,0,-1,0};
    int dj[] = {0,1,0,-1};
    REP(k,4) {
      int ni=i+di[k];
      int nj=j+dj[k];
      if (ni<0||nj<0||ni>=h||nj>=w) continue;
      if(tb[ni][nj].none()) {
        tb[ni][nj].set();
        que.emplace(ni,nj);
      }
    }
  }
}

int main() {
  while(1){
    int n;
    cin>>n;
    if (!n) break;
    vector<pair<int,int>> poly;
    vector<int> vx, vy;
    vx.push_back(-21000);
    vy.push_back(-21000);
    vx.push_back(-20100);
    vy.push_back(-20100);
    vx.push_back(21000);
    vy.push_back(21000);
    vx.push_back(20100);
    vy.push_back(20100);
    REP(i,n) {
      int x,y;
      cin>>x>>y;
      poly.emplace_back(x,y);
      vx.push_back(x);
      vy.push_back(y);
    }
    vector<pair<int,int>> rect;
    REP(i,4) {
      int x,y;
      cin>>x>>y;
      rect.emplace_back(x,y);
      vx.push_back(x);
      vy.push_back(y);
    }
    sort(ALL(vx));
    sort(ALL(vy));
    vx.erase(unique(ALL(vx)), end(vx));
    vy.erase(unique(ALL(vy)), end(vy));
    int h = vy.size();
    int w = vx.size();
    vector<vector<bitset<4>>> tb(h, vector<bitset<4>>(w, 0));
    REP(i,n) {
      int j = (i+1)%n;
      int ix, iy, jx, jy;
      tie(ix, iy) = poly[i];
      tie(jx, jy) = poly[j];
      int idix = lower_bound(ALL(vx), ix) - begin(vx);
      int idiy = lower_bound(ALL(vy), iy) - begin(vy);
      int idjx = lower_bound(ALL(vx), jx) - begin(vx);
      int idjy = lower_bound(ALL(vy), jy) - begin(vy);
      if (jx-ix != 0) {
        if (jx > ix) {
          FOR(k,idix,idjx) {
            tb[idjy-1][k].set(0);
          }
        } else {
          FOR(k,idjx,idix) {
            tb[idjy][k].set(2);
          }
        }
      } else {
        if (jy > iy) {
          FOR(k,idiy,idjy) {
            tb[k][idjx].set(1);
          }
        } else {
          FOR(k,idjy,idiy) {
            tb[k][idjx-1].set(3);
          }
        }
      }
    }
    REP(i,h)REP(j,w) {
      int di[] = {1,0,-1,0};
      int dj[] = {0,-1,0,1};
      bitset<4> flag = tb[i][j];
      if (flag.count() == 1) {
        REP(dir,4) {
          if (flag.test(dir)) {
            bfs(tb, make_pair(i+di[dir],j+dj[dir]));
          }
        }
      }
    }
    vector<vector<int>> tb2(h, vector<int>(w, 0));
    REP(i,4) {
      int j = (i+1)%4;
      int ix, iy, jx, jy;
      tie(ix, iy) = rect[i];
      tie(jx, jy) = rect[j];
      int cross2 = ix-jx;
      int idx = lower_bound(ALL(vx), jx) - begin(vx);
      int idy = lower_bound(ALL(vy), jy) - begin(vy);
      tb2[idy][idx] += (cross2 ? 1 : -1);
    }
    REP(i,h) REP(j,w-1) tb2[i][j+1] += tb2[i][j];
    REP(i,h-1) REP(j,w) tb2[i+1][j] += tb2[i][j];
    int64_t area = 0;
    REP(i,h)REP(j,w) {
      if (tb[i][j].all() && tb2[i][j] == 0)
        area += int64_t(vx[j+1] - vx[j]) * (vy[i+1] - vy[i]);
    }
    cout << area << endl;
  }
  return 0;
}

Measured memory_bytes: 3164