#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define X real()
#define Y imag()
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
typedef complex<double> P;
typedef complex<double> point;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

struct L : public vector<P> {
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

typedef vector<P> G;
typedef vector<P> polygon;

struct C {
	P p; double r;
	C(const P &p, double r) : p(p), r(r) { }
};
//??????????????????
int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;       // counter clockwise
	if (cross(b, c) < 0)   return -1;       // clockwise
	if (dot(b, c) < 0)     return +2;       // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

double getArea(const polygon& pol) {
	int n = pol.size();
	double s = 0.0;
	for(int i = 0; i < n; i++) {
		int now = i, nxt = (i + 1) % n;
		s += (pol[now].X - pol[nxt].X) * (pol[now].Y + pol[nxt].Y);
	}
	return abs(s/2.0);
}

int main(){
	int n;
	while(cin >> n && n > 0) {
		vector<P> ps;
		rep(i, n) {
			double x, y;
			cin >> x >> y;
			ps.pb({x, y});
		}
		double S = 0.0;
		S = getArea(ps);
		G rect;
		double l = INF, r = -INF, u = -INF, d = INF;
		rep(i, 4) {
			double x, y;
			cin >> x >> y;
			rect.pb({x, y});
			l = min(l, x);
			r = max(r, x);
			u = max(u, y);
			d = min(d, y);
		}
		G pp;
		rep(i, n) {
			double x, y;
			if(ps[i].X > r) x = r;
			else if(ps[i].X < l) x = l;
			else x = ps[i].X;
			if(ps[i].Y > u) y = u;
			else if(ps[i].Y < d) y = d;
			else y = ps[i].Y;
			pp.pb({x, y});
		}
		double s = 0.0;
		s = getArea(pp);
		printf("%d\n", (int)(abs(S) - abs(s) + EPS));
		//cout << S <<" " << s << endl;
	}
}