#ifndef ___Geometry_Library
#define ___Geometry_Library

// ------ Includes ------ //
#include <cmath>
#include <vector>
#include <complex>
#include <utility>
#include <algorithm>

// ------ Defines ------ //
typedef long double GType;
typedef std::complex<GType> Point;
typedef std::pair<Point, Point> Segment;

// ------ Constants ------ //
const GType EPS = 1.0e-10L;

// ------ Functions Level 1 ------ //
GType dot(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).real();
}
GType cross(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).imag();
}
int ccw(const Point& p1, const Point& p2, const Point& p3) {
	Point v1 = p2 - p1, v2 = p3 - p1;
	if (cross(v1, v2) > EPS) return +1;
	if (cross(v1, v2) < -EPS) return -1;
	if (dot(v1, v2) < -EPS) return +2;
	if (std::norm(v1) < std::norm(v2)) return -2;
	return 0;
}

// ------ Functions Level 2 ------ //
bool intersect(const Segment& s1, const Point& p1, bool segflag) {
	if (!segflag) return std::abs(cross(s1.second - p1, s1.first - p1)) < EPS;
	return (std::abs(s1.first - p1) + std::abs(s1.second - p1) - std::abs(s1.second - s1.first)) < EPS;
}
bool intersect(const Segment& s1, const Segment& s2, bool segflag) {
	if (!segflag) return cross(s1.second - s1.first, s2.first - s1.first) * cross(s1.second - s1.first, s2.second - s1.first) < EPS;
	return (ccw(s1.first, s1.second, s2.first) * ccw(s1.first, s1.second, s2.second) <= 0 && ccw(s2.first, s2.second, s1.first) * ccw(s2.first, s2.second, s1.second) <= 0);
}
Point projection(const Segment& s1, const Point& p1) {
	GType mul = dot(p1 - s1.first, s1.first - s1.second) / norm(s1.first - s1.second);
	return s1.first + (s1.first - s1.second) * mul;
}
Point reflection(const Segment& s1, const Point& p1) {
	return p1 + (projection(s1, p1) - p1) * (GType)(2);
}
GType distance(const Point& p1, const Point& p2) {
	return std::abs(p2 - p1);
}
GType distance(const Segment& s1, const Point& p1, bool segflag) {
	if (!segflag) return std::abs(p1 - projection(s1, p1));
	const Point p2 = projection(s1, p1);
	if (intersect(s1, p2, true)) return std::abs(p2 - p1);
	return std::min(std::abs(s1.first - p1), std::abs(s1.second - p1));
}
GType distance(const Segment& s1, const Segment& s2, bool segflag) {
	if (intersect(s1, s2, segflag)) return 0;
	if (!segflag) return std::min(distance(s1, s2.first, false), distance(s1, s2.second, false));
	return std::min({ distance(s1, s2.first, true), distance(s1, s2.second, true), distance(s2, s1.first, true), distance(s2, s1.second, true) });
}
Point crosspoint(const Segment& s1, const Segment& s2) {
	GType r1 = cross(s1.second - s1.first, s2.second - s2.first);
	GType r2 = cross(s1.second - s1.first, s1.second - s2.first);
	if (std::abs(r1) < EPS && std::abs(r2) < EPS) return s2.first;
	return s2.first + r2 / r1 * (s2.second - s2.first);
}

// ------ Functions Level 3 ------ //
GType area(std::vector<Point> v) {
	GType ret = 0;
	for (int i = 0; i < v.size(); i++) {
		if (i + 1 != v.size()) ret += cross(v[i], v[i + 1]);
		else ret += cross(v[i], v[0]);
	}
	return std::abs(ret / 2);
}
bool convex(std::vector<Point> v) {
	if (v.size() < 3) return false;
	int s = -3;
	for (int i = 0; i < v.size(); i++) {
		int r = ccw(v[i], v[(i != 0 ? i - 1 : v.size() - 1)], v[(i + 1 != v.size() ? i + 1 : 0)]);
		if (abs(r) == 1 && s == -3) s = r;
		if (s * r == -1) return false;
	}
	return true;
}
int contain(std::vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); i++) {
		Point a = v[i] - p, b = v[(i + 1 != v.size() ? i + 1 : 0)] - p;
		if (a.imag() > b.imag()) swap(a, b);
		if (a.imag() <= EPS && EPS < b.imag() && cross(a, b) < -EPS) in = !in;
		if (cross(a, b) == 0 && dot(a, b) <= 0) return 1;
	}
	return in ? 2 : 0;
}
std::vector<Point> convex_hull(std::vector<Point> v) {
	if (v.size() < 3) return v;
	struct sorter {
		bool operator()(const Point& p1, const Point& p2) const {
			return p1.real() < p2.real();
		}
	};
	std::sort(v.begin(), v.end(), sorter());
	std::vector<Point> u = { v[0], v[1] }, l = { v[v.size() - 1], v[v.size() - 2] };
	for (int i = 2; i < v.size(); i++) {
		for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], v[i]) >= 0; n--) u.pop_back();
		u.push_back(v[i]);
	}
	for (int i = v.size() - 3; i >= 0; i--) {
		for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], v[i]) >= 0; n--) l.pop_back();
		l.push_back(v[i]);
	}
	std::reverse(l.begin(), l.end());
	for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);
	return l;
}

#endif

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, cx, cy;
int main() {
	while (cin >> n, n) {
		vector<Point> v(n);
		vector<int> sx, sy;
		for (int i = 0; i < n; i++) {
			cin >> cx >> cy;
			v[i] = Point(cx, cy);
			sx.push_back(cx);
			sy.push_back(cy);
		}
		vector<int> rx(4), ry(4);
		for (int i = 0; i < 4; i++) {
			cin >> rx[i] >> ry[i];
		}
		int xa = *min_element(rx.begin(), rx.end());
		int ya = *min_element(ry.begin(), ry.end());
		int xb = *max_element(rx.begin(), rx.end());
		int yb = *max_element(ry.begin(), ry.end());
		sx.push_back(xa);
		sy.push_back(ya);
		sx.push_back(xb);
		sy.push_back(yb);
		sort(sx.begin(), sx.end());
		sx.erase(unique(sx.begin(), sx.end()), sx.end());
		sort(sy.begin(), sy.end());
		sy.erase(unique(sy.begin(), sy.end()), sy.end());
		int ptlx = lower_bound(sx.begin(), sx.end(), xa) - sx.begin();
		int ptly = lower_bound(sy.begin(), sy.end(), ya) - sy.begin();
		int ptrx = lower_bound(sx.begin(), sx.end(), xb) - sx.begin();
		int ptry = lower_bound(sy.begin(), sy.end(), yb) - sy.begin();
		int ret = 0;
		for (int i = ptlx + 1; i <= ptrx; i++) {
			for (int j = ptly + 1; j <= ptry; j++) {
				double mx = (sx[i - 1] + sx[i]) * 0.5, my = (sy[j - 1] + sy[j]) * 0.5;
				if (contain(v, Point(mx, my))) ret += (sx[i] - sx[i - 1]) * (sy[j] - sy[j - 1]);
			}
		}
		int res = (int)(area(v) + 0.5);
		cout << res - ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3072