#include<bits/stdc++.h>
#define INTMAX 2147483647LL
#define PII pair<int,int>
#define MK make_pair
#define re register
#define Eps (1e-10)
#define Equal(a,b) (fabs((a)-(b))<Eps)
using namespace std;
typedef long long ll;
typedef double db;
const double Pi=acos(-1.0);
const int Inf=0x3f3f3f3f;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

inline int read(){
	re int x=0,f=1,ch=getchar();
	while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-48,ch=getchar();
	return x*f;
}
inline ll readll(){
	re ll x=0,f=1,ch=getchar();
	while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-48,ch=getchar();
	return x*f;
}

struct Point{
	db x,y;
	Point(){}
	Point(db xx,db yy):x(xx),y(yy){}
	inline Point operator +(const Point &p){return Point(x+p.x,y+p.y);}
	inline Point operator -(const Point &p){return Point(x-p.x,y-p.y);}
	inline Point operator *(const db &k){return Point(x*k,y*k);}
	inline Point operator /(const db &k){return Point(x/k,y/k);}
	inline db Norm(){return x*x+y*y;}
	inline db abs(){return sqrt(Norm());}
	inline bool operator <(const Point &p)const{return x!=p.x?x<p.x:y<p.y;}
	inline bool operator ==(const Point &p)const{return fabs(x-p.x)<Eps&&fabs(y-p.y)<Eps;}
}; 

typedef Point Vector;
typedef vector<Point> Polygon;

struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point p1_,Point p2_):p1(p1_),p2(p2_){}
};
typedef Segment Line;
struct Circle{
	Point c;db r;
	Circle(Point cc,db rr):c(cc),r(rr){}
};

double norm(Vector a){return a.x*a.x+a.y*a.y;}
double abs(Vector a){return sqrt(norm(a));}
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;}

inline bool Is_Vertical(Vector a,Vector b){return Equal(dot(a,b),0.0);}
inline bool Is_Vertical(Point a1,Point a2,Point b1,Point b2){return Is_Vertical(a1-a2,b1-b2);}
inline bool Is_Vertical(Segment s1,Segment s2){return Equal(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);}

inline bool Is_Parallel(Vector a,Vector b){return Equal(cross(a,b),0.0);}
inline bool Is_Parallel(Point a1,Point a2,Point b1,Point b2){return Is_Parallel(a1-a2,b1-b2);}
inline bool Is_Parallel(Segment s1,Segment s2){return Equal(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);}

Point Project(Segment s,Point p){
	Vector bse=s.p2-s.p1;
	double res=dot(p-s.p1,bse)/norm(bse);
	return s.p1+bse*res;
}
Point Reflect(Segment s,Point p){return p+(Project(s,p)-p)*2.0;}

inline int CCW(Point p0,Point p1,Point p2){
	Vector a=p1-p0,b=p2-p0;
	if(cross(a,b)>Eps) return COUNTER_CLOCKWISE;
	if(cross(a,b)<-Eps)return CLOCKWISE;
	if(dot(a,b)<-Eps)  return ONLINE_BACK;
	if(a.Norm()<b.Norm()) return ONLINE_FRONT;
	return ON_SEGMENT; 
}

inline bool Is_Intersect(Point p1,Point p2,Point p3,Point p4){return (CCW(p1,p2,p3)*CCW(p1,p2,p4)<=0)&&(CCW(p3,p4,p1)*CCW(p3,p4,p2)<=0);} 
inline bool Is_Intersect(Segment s1,Segment s2){return Is_Intersect(s1.p1,s1.p2,s2.p1,s2.p2);}

inline double Get_DistanceLP(Segment s,Point p){
	return abs(cross(s.p2-s.p1,p-s.p1)/abs(s.p2-s.p1));
}
inline double Get_DistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1,p-s.p1)<0.0) return abs(p-s.p1);
	if(dot(s.p1-s.p2,p-s.p2)<0.0) return abs(p-s.p2);
	return Get_DistanceLP(s,p);
}
inline double Get_Distance(Segment s1,Segment s2){
	if(Is_Intersect(s1,s2)) return 0.0;
	return min(min(Get_DistanceSP(s1,s2.p1),Get_DistanceSP(s1,s2.p2)),min(Get_DistanceSP(s2,s1.p1),Get_DistanceSP(s2,s1.p2)));
}
inline double Get_Distance(Point p1,Point p2,Point p3,Point p4){return Get_Distance(Segment(p1,p2),Segment(p3,p4));}
inline Point Get_Crosspoint(Segment s1,Segment s2){
	Vector bse=s2.p2-s2.p1;
	double d1=abs(cross(bse,s1.p1-s2.p1));
	double d2=abs(cross(bse,s1.p2-s2.p1));
	double t=d1/(d1+d2);
	return s1.p1+(s1.p2-s1.p1)*t; 
}

inline Point Get_Crosspoint(Point p1,Point p2,Point p3,Point p4){return Get_Crosspoint(Segment(p1,p2),Segment(p3,p4)); }

inline int Contains(Polygon g,Point p){
	int n=g.size();bool f=false;
	for(int i=0;i<n;++i){
		Point a=g[i]-p,b=g[(i+1)%n]-p;
		if(fabs(cross(a,b))<Eps&&dot(a,b)<Eps) return 1;
		if(a.y>b.y) swap(a,b);
		if(a.y<Eps&&Eps<b.y&&cross(a,b)>Eps) f=!f;
	}
	return (f?2:0);
} 
inline double Area(Polygon s){
	double res=0;
	for(int i=0;i<(int)s.size();++i)
		res+=cross(s[i],s[(i+1)%(int)s.size()])/2.0;
	return abs(res);
}
inline bool Is_Convex(Polygon p){
	bool f=true;int n=p.size();
	for(int i=0;i<n;++i){
		int t=CCW(p[(i+n-1)%n],p[i],p[(i+1)%n]);
		f&=t!=CLOCKWISE;
	}
	return f;
}
int n,q;
int main(){
	n=read();
	Polygon p(n); 
	for(int i=0;i<n;++i)
		p[i].x=read(),p[i].y=read();
	q=read();
	while(q--){
		Point a;
		a.x=read();a.y=read();
		printf("%d\n",Contains(p,a));
	}
	return 0;
}



Measured memory_bytes: 3216