#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

#include <utility>
template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T, typename E>
void compress_insert(vector<T> &inserter, pair<vector<T> &, vector<E> &> pr) {
    for (T &val : pr.first) {
        inserter.push_back(val);
    }
}
template<typename T, typename Head, typename... Args>
void compress_insert(vector<T> &inserter, Head head, Args... args) {
    compress_insert(inserter, head);
    compress_insert(inserter, args...);
}
template<typename T, typename E>
void compress_update(vector<T> &inserter, pair<vector<T> &, vector<E> &> pr) {
    for (unsigned int i = 0; i < pr.first.size(); i++) {
        pr.second[i] = static_cast<int>(lower_bound(inserter.begin(), inserter.end(), pr.first[i]) - inserter.begin());
    }
}
template<typename T, typename Head, typename... Args>
void compress_update(vector<T> &inserter, Head head, Args... args) {
    compress_update(inserter, head);
    compress_update(inserter, args...);
}
template<typename T, typename... Args>
size_t compress(vector<T> &inserter, Args... args) {
    compress_insert(inserter, args...);
    sort(inserter.begin(), inserter.end());
    inserter.erase(unique(inserter.begin(), inserter.end()), inserter.end());
    compress_update(inserter, args...);
    return inserter.size();
}
#include <functional>
template<typename T, typename E>
auto refer(vector<T> &a, vector<E> &b) {
    return make_pair(ref(a), ref(b));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n, n) {
        vector<int> x(n), y(n);
        REP(i, 0, n) {
            cin >> x[i] >> y[i];
        }
        vector<int> carX(4), carY(4);
        REP(i, 0, 4) {
            cin >> carX[i] >> carY[i];
        }
        vector<int> resX, resY;

        int W = compress(resX, refer(x, x), refer(carX, carX));
        int H = compress(resY, refer(y, y), refer(carY, carY));
        int minX = *min_element(carX.begin(), carX.end());
        int minY = *min_element(carY.begin(), carY.end());
        int maxX = *max_element(carX.begin(), carX.end());
        int maxY = *max_element(carY.begin(), carY.end());

        /*
        dump(minX);
        dump(minY);
        dump(maxX);
        dump(maxY);
        */

        ll ans = 0;
        REP(i, 0, H - 1) {
            int TX = 0;
            REP(j, 0, W - 1) {
                REP(k, 0, n) {
                    int kk = (k + 1) % n;
                    if (x[k] == j && x[kk] == j && ((y[k] <= i && i < y[kk]) || (y[kk] <= i && i < y[k]))) {
                        TX = 1 - TX;
                        break;
                    }
                }
                //dump(TX);
                if (TX && ((j < minX || maxX <= j) || (i < minY || maxY <= i))) {
                    ans += ll(resX[j + 1] - resX[j]) * (resY[i + 1] - resY[i]);
                    //dump(ans);
                }
            }
            //cout << endl;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3204