#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cctype>
#include<vector>
#include<cassert>
#include<cmath>
using namespace std;


#define reg register
typedef long long ll;
typedef double db;
#define rep(i,a,b) for(reg int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(reg int i=a,i##end=b;i>=i##end;--i)

#define Mod1(x) ((x>=P)&&(x-=P))
#define Mod2(x) ((x<0)&&(x+=P))
#define pb push_back
template <class T> inline void cmin(T &a,T b){ ((a>b)&&(a=b)); }
template <class T> inline void cmax(T &a,T b){ ((a<b)&&(a=b)); }

char IO;
template <class T=int> T rd(){
	T s=0; int f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

namespace Geometry{
	const db eps=1e-7;
	const db inf=1.0/0.0,INF=1e18;
	const db Nan=0.0/0.0;
	const db PI=acos(db(-1));
	int sign(db x){ return x<-eps?-1:x>eps; }
	int cmp(db x,db y){ return sign(x-y); }
	struct Point{
		db x,y;
		Point(){; }
		Point(db a,db b){ x=a,y=b; }
		db len(){ return sqrt(x*x+y*y); }
		Point Rot(db k){ return Point(x*cos(k)-y*sin(k),x*sin(k)+y*cos(k)); }
		Point Unit(){ db t=len(); return Point(x/t,y/t); }
		void Read(){ x=rd(),y=rd(); }
		void Show(){ printf("(%.2lf,%.2lf)",x,y); }
	};
	typedef Point Vector;
	Vector operator + (Vector a,Vector b){ return Vector(a.x+b.x,a.y+b.y); }
	Vector operator - (Vector a,Vector b){ return Vector(a.x-b.x,a.y-b.y); }
	db operator * (Vector a,Vector b){ return a.x*b.x+a.y*b.y; }
	db operator ^ (Vector a,Vector b){ return a.x*b.y-a.y*b.x; }
	Vector operator * (Vector a,db x){ return Vector(a.x*x,a.y*x); }
	Vector operator * (db x,Vector a){ return Vector(a.x*x,a.y*x); }
	Vector operator / (Vector a,db x){ return Vector(a.x/x,a.y/x); }
	int operator == (Point a,Point b){ return cmp(a.x,b.x)==0 && cmp(a.y,b.y)==0; }
	db Ang(Vector a){ return atan2(a.y,a.x); }
	db Dis(Point x,Point y){ return (x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y); }
	db Ang(Vector x,Vector y){ return acos(x*y/(x.len()*y.len())); }

	int Get(Vector a){
		if(a.x>0 && a.y>=0) return 0;
		if(a.x<=0 && a.y>0) return 1;
		if(a.x<0 && a.y<=0) return 2;
		return 3;
	}
	int operator < (Vector a,Vector b) { 
		if(Get(a)==Get(b)) return sign(a^b)>0;
		return Get(a)<Get(b);
	}
	int operator <= (Vector a,Vector b){ return a==b || a<b; }
	int operator > (Vector a,Vector b){ return b<a; }
	int operator >= (Vector a,Vector b){ return b<=a; }

	db Calc_Area(vector <Point> V){
		int n=V.size(); db res=0;
		rep(i,0,V.size()-1) res+=V[i]^V[(i+1)%n];
		return fabs(res/2);
	}
	int Check_Convex(vector <Point> V){
		int n=V.size(),fl=1;
		rep(i,0,V.size()-1) {
			int j=(i+1)%n,k=(i+2)%n;
			if( ((V[i]-V[j])^(V[k]-V[j])) < 0) fl=0;
		}
		return fl;
	}

	int On(Point x,Vector y,Point z,int k=0){  // z On  Segment [x,x+y]
		z=z-x; 
		if(!k) return y*z>=-eps && cmp(z^y,0)==0 && y.len()+eps>=z.len();
		else return y*z>=-eps && cmp(z^y,0)==0 && y.len()>z.len();
	}

	struct Line{
		db k,b;
		Line(){ ; } 
		Line(db x,db y){ k=x,b=y; }
		Line(Point x,Point y) {
			assert(cmp(x.x,y.x) || cmp(x.y,y.y));
			if(cmp(x.x,y.x)==0) k=inf,b=x.x;
			else {
				db t=(y.y-x.y)/(y.x-x.x);
				k=t,b=x.y-x.x*k;
			}
		}
		db operator [] (const db x){ return k==inf? Nan : k*x+b; }
	};
	int operator == (Line a,Line b){
		if(a.k==inf && b.k==inf) return cmp(a.b,b.b)==0;
		if(a.k==inf || b.k==inf) return 0;
		return cmp(a.b,b.b)==0 && cmp(a.k,b.k)==0;
	}
	db operator & (Line x,Line y){ 
		assert(fabs(x.k-y.k)>eps);
		if(y.k==inf) swap(x,y);
		if(x.k==inf) return x.b;
		return (x.b-y.b)/(y.k-x.k); 
	}
	db Dis(Line x,Point y){ 
		if(x.k==inf) return abs(x.b-y.x);
		return fabs((x[y.x]+y.y)/sqrt(x.k*x.k+1)); 
	}
	int Parallel(Line x,Line y){ 
		if(x.k==inf && y.k==inf) return 1;
		if(x.k==inf || y.k==inf) return 0;
		return cmp(x.k,y.k)==0;
	}

	/*struct Circle{
		Point x; db r;
		Circle(){ ; }
		Circle(Point _x,db _r){ x=_x,r=_r; }
		Circle(db _x,db _y,db _r){ x=Point(_x,_y),r=_r; }
	};
	int In(Circle a,Circle b){ return a.r*a.r>=Dis(a.x,b.x); }
	int Check_Cross(Circle a,Circle b) { return cmp((a.r+b.r)*(a.r+b.r),Dis(a.x,b.x)); }
	vector <Point> operator & (Circle a,Circle b){
		int t=Check_Cross(a,b);
		if(t<0) return {};
		;
		;
		return {};
	}*/
}
using namespace::Geometry;


const int N=110;

int n;
Point V[N];



int main(){
	n=rd();
	rep(i,1,n) V[i].Read();
	db rotk=0.3146;
	rep(i,1,n) V[i]=V[i].Rot(rotk);
	rep(kase,1,rd()) {
		Point X; X.Read(); X=X.Rot(rotk); 
		int c=0,fl=0;
		rep(i,1,n) {
			int j=i%n+1;
			if(On(V[i],V[j]-V[i],X)) fl=1;
			Point x=V[i]+((V[j]-V[i])/(V[j]-V[i]).y)*(X.y-V[i].y);
			//((V[j]-V[i])/(V[j]-V[i]).y).Show();
			//x.Show(); puts("");
			if(x.x>=X.x && On(V[i],V[j]-V[i],x,1)) c++;
		}

		if(fl) puts("1");
		else if(c&1) puts("2");
		else puts("0");
	}
}















Measured memory_bytes: 3108