#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

typedef long double db;
const db EPS = 1e-9;
const db pi=acos(-1.0);
  
inline int sign(db a) { return a < -EPS ? -1 : a > EPS; }
  
inline int cmp(db a, db b){ return sign(a-b); }
  
struct P {
	db x, y;
	P() {}
	P(db _x, db _y) : x(_x), y(_y) {}
	P operator+(P p) { return {x + p.x, y + p.y}; }
	P operator-(P p) { return {x - p.x, y - p.y}; }
	P operator*(db d) { return {x * d, y * d}; }
	P operator/(db d) { return {x / d, y / d}; }
 
	bool operator<(P p) const { 
		int c = cmp(x, p.x);
		if (c) return c == -1;
		return cmp(y, p.y) == -1;
	}
 
	bool operator==(P o) const{
		return cmp(x,o.x) == 0 && cmp(y,o.y) == 0;
	}
 
	db dot(P p) { return x * p.x + y * p.y; }
	db det(P p) { return x * p.y - y * p.x; }
	 
	db distTo(P p) { return (*this-p).abs(); }
	db alpha() { return atan2(y, x); }
	void read() {
		int a,b;
		scanf("%d%d",&a,&b);
		x=a; y=b;
	}
	db abs() { return sqrt(abs2());}
	db abs2() { return x * x + y * y; }
	P rot90() { return P(-y,x);}
	P unit() { return *this/abs(); }
	int quad() const { return sign(y) == 1 || (sign(y) == 0 && sign(x) >= 0); }
	P rot(db an){ return {x*cos(an)-y*sin(an),x*sin(an) + y*cos(an)}; }
};

db sqr(db x){ return x*x; }

struct P3{
    db x,y,z;
    P3 operator+(P3 o){ return {x+o.x,y+o.y,z+o.z}; }
    P3 operator-(P3 o){ return {x-o.x,y-o.y,z-o.z}; }
    db operator*(P3 o){ return x*o.x+y*o.y+z*o.z; }
    P3 operator^(P3 o){ return {y*o.z-z*o.y,z*o.x-x*o.z,x*o.y-y*o.x}; }
    P3 operator*(db o){ return {x*o,y*o,z*o}; }
    P3 operator/(db o){ return {x/o,y/o,z/o}; }

    db abs2(){ return sqr(x) + sqr(y) + sqr(z); }
    db abs(){ return sqrt(abs2()); }

    P3 norm(){ return *this / abs(); } 
    bool operator<(P3 o){
        if(cmp(x,o.x) != 0) return x < o.x;
        if(cmp(y,o.y) != 0) return y < o.y;
        return cmp(z,o.z) == -1;
    }
    bool operator==(P3 o){
        return cmp(x,o.x) == 0 && cmp(y,o.y) == 0 && cmp(z,o.z) == 0;
    }
    void read(){
    	int a,b,c;
    	scanf("%d%d%d",&a,&b,&c);
//    	scanf("%lf%lf%lf",&x,&y,&z);
    	x=a, y=b, z=c;
    }
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

int contain(vector<P> ps, P p){ //2:inside,1:on_seg,0:outside
	int n = ps.size(), ret = 0; 
	rep(i,0,n){
		P u=ps[i],v=ps[(i+1)%n];
		if(cmp(u.y,v.y)<=0) swap(u,v);
		if(cmp(p.y,u.y) >0 || cmp(p.y,v.y) <= 0) continue;
		ret ^= crossOp(p,u,v) > 0;
	}
	return ret;
}

const int N=101000;
int n,m,ret[N];
P p[N],q[N];

struct event {
	db x;
	int val;
	P a,b;
};
vector<event> evt;
db X;
db gety(P a,P b) {
	return (a.y*(b.x-X)+b.y*(X-a.x))/(b.x-a.x);
}
bool operator < (const event&a, const event &b) {
	db ya=gety(a.a,a.b),yb=gety(b.a,b.b);
	return cmp(ya,yb)==-1;
}

struct mydb {
	db x;
};
bool operator == (const mydb &a, const mydb &b) {
	return cmp(a.x,b.x)==0;
}
bool operator < (const mydb &a, const mydb &b) {
	return cmp(a.x,b.x)==-1;
}

set<PII> w;
int main() {
	db ang=rnd(100000)*1e-5*2*pi;
	scanf("%d",&n);
	rep(i,0,n) {
		p[i].read();
		w.insert(mp(p[i].x,p[i].y));
		p[i]=p[i].rot(ang);
	}
	scanf("%d",&m);
	rep(i,0,m) {
		q[i].read();
		if (w.count(mp(q[i].x,q[i].y))) ret[i]=1;
		else {
			q[i]=q[i].rot(ang);
			evt.pb((event) {q[i].x,i,q[i],q[i]+P(1,0)});
		}
	}
	rep(i,0,n) {
		auto a=p[i],b=p[(i+1)%n];
		if (a.x<b.x) {
			evt.pb((event){a.x, 19999998,a,b});
			evt.pb((event){b.x,-20000002,a,b});
		} else {
			evt.pb((event){b.x, 20000002,b,a});
			evt.pb((event){a.x,-19999998,b,a});
		}
	}
	vector<mydb> vx;
	for (auto p:evt) vx.pb((mydb){p.x});
	vx.pb((mydb){-1e9});
	vx.pb((mydb){1e9});
	sort(all(vx)); vx.erase(unique(all(vx)),vx.end());
	sort(all(evt),[&](const event &a,const event &b){
		return cmp(a.x,b.x)==0?a.val<b.val:a.x<b.x;
	});
	set<event> st;
	for (auto p:evt) {
		auto it=lower_bound(all(vx),(mydb){p.x});
		if (p.val>=19999998) {
			X=(it->x+(it+1)->x)*0.5;
			st.insert(p);
		} else if (p.val<=-19999998) {
			X=(it->x+(it-1)->x)*0.5;
			auto it=st.lower_bound(p);
			assert(it!=st.end());
			st.erase(it);
		} else {
			X=it->x;
			auto it=st.lower_bound(p);
			if (it==st.end()) ret[p.val]=0;
			else {
				if (cmp(gety(it->a,it->b),gety(p.a,p.b))==0) ret[p.val]=1;
				else ret[p.val]=it->val==20000002?2:0;
			}

		}
	}
	rep(i,0,m) printf("%d\n",ret[i]);
}



Measured memory_bytes: 3800