#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct Line {
	ll lx, rx, y;
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	while(cin >> N, N) {
		vector<ll> x(N), y(N);
		vector<ll> xs;
		for(int i = 0; i < N; i++) {
			cin >> x[i] >> y[i];
			xs.push_back(x[i]);
		}

		vector<ll> ax(4), ay(4);
		for(int i = 0; i < 4; i++) {
			cin >> ax[i] >> ay[i];
			xs.push_back(ax[i]);
		}
		sort(xs.begin(), xs.end());
		xs.erase(unique(xs.begin(), xs.end()), xs.end());

		vector<Line> ls, cls;
		for(int i = 0; i < N; i++) {
			if(y[i] == y[(i + 1) % N]) {
				ll lx = min(x[i], x[(i + 1) % N]);
				ll rx = max(x[i], x[(i + 1) % N]);
				ls.push_back({ lx, rx, y[i] });
			}
		}
		for(int i = 0; i < 4; i++) {
			if(ay[i] == ay[(i + 1) % 4]) {
				ll lx = min(ax[i], ax[(i + 1) % 4]);
				ll rx = max(ax[i], ax[(i + 1) % 4]);
				cls.push_back({ lx, rx, ay[i] });
			}
		}

		typedef pair<ll, int> P; // <y, curtain>

		ll ans = 0;
		for(int i = 0; i < (int)xs.size() - 1; i++) {
			ll lx = xs[i], rx = xs[i + 1];
			ll w = xs[i + 1] - xs[i];
			vector<P> ys;
			for(auto l : ls) {
				if(l.lx <= lx && rx <= l.rx) {
					ys.push_back({ l.y, 0 });
				}
			}
			for(auto l : cls) {
				if(l.lx <= lx && rx <= l.rx) {
					ys.push_back({ l.y, 1 });
				}
			}

			sort(ys.begin(), ys.end());
			bool in = false, in_curtain = false;
			for(int j = 0; j < (int)ys.size() - 1; j++) {
				if(ys[j].second) {
					in_curtain = !in_curtain;
				}
				else {
					in = !in;
				}
				if(in && !in_curtain) {
					ans += w * abs(ys[j].first - ys[j + 1].first);
				}
			}
		}
		cout << ans << endl;
	}
}