#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

//circle of points

using db = double;
constexpr double EPS = 1e-10;
constexpr bool eq(const db& x,const db& y){return abs(x-y)<EPS;}
struct point{
    db x=0,y=0;
    constexpr point(const db& x=0,const db& y=0):x(x),y(y){}
    constexpr bool operator==(const point& r)const{return eq(x,r.x)&&eq(y,r.y);};
    constexpr bool operator!=(const point& r)const{return !(*this==r);};
    constexpr bool operator<(const point& r)const{return (eq(x,r.x))?(y<r.y):(x<r.x);};
    constexpr bool operator>(const point& r)const{return (eq(x,r.x))?(y>r.y):(x>r.x);};
    constexpr point operator+(const point& r)const{return point(*this)+=r;}
    constexpr point operator+=(const point& r){
        x+=r.x;y+=r.y;
        return *this;
    }
    constexpr point operator-(const point& r)const{return point(*this)-=r;}
    constexpr point operator-=(const point& r){
        x-=r.x;y-=r.y;
        return *this;
    }
    constexpr point operator*(const db& r)const{return point(*this)*=r;}
    constexpr point operator*=(const db& r){
        x*=r;y*=r;
        return *this;
    }
    constexpr point operator*(const point& r)const{return point(*this)*=r;}
    constexpr point operator*=(const point& r){
        db tmp=x;
        x=x*r.x-y*r.y;
        y=tmp*r.y+y*r.x;
        return *this;
    }
    constexpr point operator/(const double& r)const{return point(*this)/=r;}
    constexpr point operator/=(const double& r){
        x/=r;y/=r;
        return *this;
    }
};
db norm(const point& a){return a.x*a.x+a.y*a.y;}
double abs(const point& a){return sqrt(a.x*a.x+a.y*a.y);}
db dot(const point& a,const point& b){return a.x*b.x+a.y*b.y;}
db cross(const point& a,const point& b){return a.x*b.y-a.y*b.x;}
point projection(const point& p,const point& b){return b*dot(p,b)/norm(b);}
point unit_vec(const point& p){return p/abs(p);}
point normal_vec(const point& p){return p*point(0,1);}
point rotation(const point& center,const point& p,const point& rot){return rot*(p-center)+center;}
double area(const point& a,const point& b,const point& c){return cross(b-a,c-a)/2;}

struct Line{
    point a,b;
    constexpr Line(const point& a=point(0,0),const point& b=point(0,0)):a(a),b(b){}
    constexpr Line(const double& A,const double& B,const double& C){ // Ax + By + C = 0
        if(eq(A,0)&&eq(B,0)) assert(-1);
        else if(eq(B,0)){
            a = point(-C/A,0);
            b = point(-C/A,1);
        }else{
            a = point(0,-C/B);
            b = point(1,-(A+C)/B);
        }
    }
};
bool is_orthoonal(const Line& l,const Line& r){return eq(dot(l.b-l.a,r.b-r.a),0);}
bool is_pararell(const Line& l,const Line& r){return eq(cross(l.b-l.a,r.b-r.a),0);}
bool on_Line(const Line& l,const point& p){return eq(dot(p-l.a,l.b-l.a),0);}
double dis_Lp(const Line& l,const point& p){return abs(cross(l.b-l.a,p-l.a))/abs(l.b-l.a);}
point Line_intersect(const Line& l,const Line& r){
    point lv=l.b-l.a,rv=r.b-r.a;
    return l.a + lv * abs(cross(r.b-l.a,rv) / cross(lv,rv)); 
}
Line vertical_bisector(const point& p,const point& q){return Line((p+q)/2,rotation((p+q)/2,q,point(0,1)));}
using Segment = Line;
bool on_Segment(const Segment& s,const point& p){
    return ( abs(s.a-p)+abs(s.b-p)<=abs(s.a-s.b)+EPS );
}
bool is_segment_intersect(const Segment& s,const Segment& t){
    return  (cross(s.b-s.a,t.a-s.a) * cross(s.b-s.a,t.b-s.a) < EPS) &&
            (cross(t.b-t.a,s.a-t.a) * cross(t.b-t.a,s.b-t.a) < EPS);
}
point segment_intersect(const Segment& s,const Segment& t){
    double d1 = dis_Lp(s,t.a);
    double d2 = dis_Lp(s,t.b); 
    double p = d1/(d1+d2);
    return t.a + (t.b-t.a)*p;
}

bool on_circle(point cen,point p){
    return ( (cen.x-p.x)*(cen.x-p.x)+(cen.y-p.y)*(cen.y-p.y)<=1.0+EPS );
}

int main(){
    int n;
    cin >> n;
    vector<point> polygon(n);
    vector<Segment> s(n);
    rep(i,n) cin >> polygon[i].x >> polygon[i].y;
    rep(i,n) s[i] = Segment(polygon[i],polygon[(i+1)%n]);
    //rep(i,n) cout << s[i].a.x << " " << s[i].a.y << " " << s[i].b.x << " " << s[i].b.y << endl;
    int q;
    cin >> q;
    while(q--){
        int ans = -1;
        point p;
        cin >> p.x >> p.y;
        rep(i,n){
            if(on_Segment(s[i],p)){
                ans = 1;
            }
        }
        if(ans==1){cout<<ans<<endl;continue;}
        int res = 0;
        point zero = point(13490,-18911);
        Line l = Line(p,zero);
        rep(i,n){
            if(is_pararell(s[i],l)) continue;
            if(is_segment_intersect(s[i],l)) ++ res;
        }
        if(res%2==1) cout << 2 << endl;
        else cout << 0 << endl; 
    }
    return 0;
}


Measured memory_bytes: 3224