#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

#define EPS (1e-10)

class P{
public:
	double x,y;
	
	P(double _x=0, double _y=0):x(_x),y(_y){};
	P operator + (const P &p)const{ return P( x+p.x , y+p.y ); }
	P operator - (const P &p)const{ return P( x-p.x, y-p.y); }
	P operator * (const double k)const{ return P( x*k , y*k);}
	P operator / (const double k)const{ return P( x/k, y/k);}
	
	bool operator == (const P &p){return ( fabs(x-p.x)<EPS && fabs(y-p.y)<EPS); }
	bool operator < (const P &p) const{ return ( x!=p.x ? x<p.x:y<p.y); }
	
	double norm(){ return x*x+y*y; }
	double abs() { return sqrt(norm()); }
};

struct S{P p1,p2;};
typedef P Vector;

double dot (Vector a, Vector b) { return a.x*b.x+a.y*b.y; }
double cross(Vector a, Vector b) { return a.x*b.y-a.y*b.x; }

int ccw(P p0, P p1, P p2){
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	
	if( cross(a,b) > EPS) return 1;
	if( cross(a,b) < -EPS) return -1;
	if( dot(a,b) < -EPS) return 2;
	if( a.norm() < b.norm() ) return -2;
	
	return 0;
}

bool intersect(P p1,P p2,P p3,P p4){	//??????????????????
	return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

P getCrossPoint(S s1,S s2){				//???????????????
	Vector base = s2.p2 - s2.p1;
	double d1 = abs(cross(base, s1.p1 - s2.p1));
	double d2 = abs(cross(base, s1.p2 - s2.p1));
	double t = d1/(d1+d2);
	return s1.p1 + (s1.p2 - s1.p1) * t;
}


int main(){
	int n;
	while(cin>>n&&n){
		vector<P> p(n);
		rep(i,n){
			int x,y;
			cin>>x>>y;
			p[i] = P(x+30000,y+30000);	//??§?¨??????£???
		}
		
		int min_x=INF,max_x=-INF,min_y=INF,max_y=-INF;	//???????????????XY??§?¨???? ??????????????§
		rep(i,4){
			int x,y;
			cin>>x>>y;
			x+=30000;	//??§?¨??????£???
			y+=30000;	//??§?¨??????£???
			min_x = min(x,min_x);
			max_x = max(x,max_x);
			min_y = min(y,min_y);
			max_y = max(y,max_y);
		}
		
		vector<S> edge;	//????§???¢?????????
		rep(i,n){
			edge.pb(S{p[i],p[(i+1)%n]});
		}
		
		
		ll ans=0;
		for(double y = 0.5;y<50100.5;y++){	//XY?????¢???y??????????????¨??¢?´¢
			S line = S{P(-1,y),P(50100,y)};	//Y??§?¨????y??¨????????´???(?????????????????§??¨???)
			vector<pii> crs;	//????¨????line??¨?????????????????????X??§?¨?????????? (second==0:??????????????¨?????? , second==1:????§???¢??¨??????)
			
			rep(i,n){	//line??¨???????????????????????¢?´¢??????crs???????????????
				if( intersect(line.p1,line.p2,edge[i].p1,edge[i].p2) ){
					P res = getCrossPoint(line, edge[i]);
					crs.pb(pii(res.x+EPS,1));
				}
			}
			
			if(min_y<y && y<max_y){	//line???Y??§?¨??????????????????? ??????~???????????? ???????????¨???
				crs.pb(pii(min_x,0));
				crs.pb(pii(max_x,0));
			}
			sort(all(crs));
			
			
			//status  ???->0 , ??????????????????->1 , ?????????->2 , ????????????->3
			int  status = 0;
			int bef_point=-INF;
			rep(i,crs.size()){
				int x_point = crs[i].first;	//?????????????????????X??§?¨?
				int st = crs[i].second;		//??????????????????????????????????????¨?????????????????¨?????????????????¨???
				
				if(st==0){	//????????????
					if(status==0)		status = 1;
					else if(status==1)	status = 0;
					else if(status==2){
						ans+=x_point-bef_point;
						status = 3;
					}
					else if(status==3)	status = 2;
				}
				
				else{	//???
					if(status==0)		status = 2;
					else if(status==1)	status = 3;
					else if(status==2){
						ans+=x_point-bef_point;
						status = 0;
					}
					else if(status==3)	status = 1;
				}
				
				bef_point = x_point;
			}
		}
		cout<<ans<<endl;
	}
}