#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

typedef pair<int, P> speP;
int n;
void solve() {
	vector<P> p(n);
	rep(i, n) {
		cin >> p[i].first >> p[i].second;
	}
	int mx[2] = { mod,-mod }, my[2] = { mod,-mod };
	rep(i, 4) {
		int a, b; cin >> a >> b;
		mx[0] = min(mx[0], a);
		mx[1] = max(mx[1], a);
		my[0] = min(my[0], b);
		my[1] = max(my[1], b);
	}
	p.push_back(p[0]);

	vector<speP> v;
	rep(i, n) {
		if (p[i].first == p[i + 1].first) {
			int le = p[i].second, ri = p[i+1].second;
			if (le > ri)swap(le, ri);
			v.push_back({ p[i].first,{le,ri} });

		}
	}
	sort(v.begin(), v.end());
	int cur = -mod;
	vector<P> z;
	ll ans = 0;
	//cout << v.size() << endl;
	rep(i, v.size()) {
		sort(z.begin(), z.end());
		/*cout << i << endl;
		rep(j, z.size()) {
			cout << z[j].first << " " << z[j].second << endl;
		}*/
		int nx = v[i].first;
		if (i > 0&&v[i].first>v[i-1].first) {
			rep(j, z.size()) {
				int ley = z[j].first, riy = z[j].second;
				ll ad=(riy - ley)*(nx - cur);
				int dx = min(mx[1], nx) - max(mx[0], cur);
				dx = max(dx, 0);
				int dy = min(my[1], riy) - max(my[0], ley);
				dy = max(dy, 0);
				ad -= dx * dy;
				//cout << "! " << ad << endl;
				ans += ad;
			}
		}
		int le = v[i].second.first, ri = v[i].second.second;
		bool f = true;
		rep(j, z.size()) {
			if (z[j].first <= le && ri <= z[j].second) {
				P nle = { z[j].first,le };
				P nri = { ri,z[j].second };
				z.erase(z.begin() + j);
				if(nri.first!=nri.second)z.insert(z.begin()+j, nri);
				if(nle.first!=nle.second)z.insert(z.begin()+j, nle);
				f = false; break;
			}
		}
		if (f) {
			rep(j, z.size()) {
				if (z[j].first == ri) {
					P nex = { le,z[j].second };
					z.erase(z.begin() + j);
					z.insert(z.begin() + j, nex);
					f = false;
					break;
				}
				if (z[j].second == le) {
					if (j + 1 < z.size() && z[j + 1].first == ri) {
						P nex = { z[j].first,z[j+1].second };
						z.erase(z.begin() + j);
						z.erase(z.begin() + j);
						z.insert(z.begin() + j, nex); 
						f = false;
						break;
					}
					else {
						P nex = { z[j].first,ri };
						z.erase(z.begin() + j);
						z.insert(z.begin() + j, nex);
						f = false;
						break;
					}
				}
			}
			if (f) {
				z.push_back({ le,ri });
			}
		}
		cur = nx;
	}
	//cout << "ans is" << endl;
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n, n) {
		solve();
	}
	//stop
	return 0;
}


Measured memory_bytes: 3172