#include<bits/stdc++.h>
using namespace std;

struct CWW{
    CWW(){
        cin.tie(0);
        ios_base::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
}STAR;

using D=double;

const D EPS=1e-8;
const D INF=1e9;

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

using Point=complex<D>;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Line{
    Point p1,p2;
    Line(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point c;
    D r;
    Circle(const Point &c=Point(),const D &r=0.0):c(c),r(r){}
};

using Polygon=vector<Point>;

#define EQ(a,b) (abs((a)-(b))<EPS)

namespace std{
    bool operator<(const Point &a,const Point &b){
        if(!EQ(real(a),real(b)))return real(a)<real(b);
        return imag(a)+EPS<imag(b);
    }
}

istream& operator>>(istream &is,Point &a){
    D x,y;
    is>>x>>y;
    a=Point(x,y);
    return is;
}

ostream& operator<<(ostream& os,const Point &a){
    os<<real(a)<<" "<<imag(a);
    return os;
}

istream& operator>>(istream &is,Line &l){
    Point p1,p2;
    is>>p1>>p2;
    l=Line(p1,p2);
    return is;
}

istream& operator>>(istream &is,Segment &s){
    Point p1,p2;
    is>>p1>>p2;
    s=Segment(p1,p2);
    return is;
}

D dot(const Point &a,const Point &b){
    return real(a)*real(b)+imag(a)*imag(b);
}

D cross(const Point &a,const Point &b){
    return real(a)*imag(b)-imag(a)*real(b);
}

Point projection(const Point &a,const Point &b){
    return a*real(b/a);
}

Point projection(const Line &l,const Point &a){
    return l.p1+projection(l.p2-l.p1,a-l.p1);
}

Point reflection(const Line &l,const Point &a){
    Point p=projection(l,a);
    return 2.0*p-a;
}

int ccw(Point a,Point b,Point c){
    b-=a;c-=a;
    if(cross(b,c)>EPS)return COUNTER_CLOCKWISE;
    if(cross(b,c)<-EPS)return CLOCKWISE;
    if(dot(b,c)<-EPS)return ONLINE_BACK;
    if(norm(b)+EPS<norm(c))return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool isOrthogonal(const Point &a,const Point &b){
    return EQ(dot(a,b),0.0);
}

bool isOrthogonal(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return isOrthogonal(a2-a1,b2-b1);
}

bool isOrthogonal(const Line &l,const Line &m){
    return isOrthogonal(l.p1,l.p2,m.p1,m.p2);
}

bool isParallel(const Point &a,const Point &b){
    return EQ(cross(a,b),0.0);
}

bool isParallel(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(const Line &l,const Line &m){
    return isParallel(l.p1,l.p2,m.p1,m.p2);
}

bool intersect(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return ccw(a1,a2,b1)*ccw(a1,a2,b2)<=0&&
            ccw(b1,b2,a1)*ccw(b1,b2,a2)<=0;
}

bool intersect(const Segment &s,const Segment &t){
    return intersect(s.p1,s.p2,t.p1,t.p2);
}

Point crossPoint(const Segment &s1,const Segment &s2){
    Point  base=s2.p2-s2.p1;
    D d1=abs(cross(base,s1.p1-s2.p1));
    D d2=abs(cross(base,s1.p2-s2.p1));

    D t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}

D distance(const Line &l,const Point &p){
    return distance(projection(l,p),p);
}

D distance(const Line &l,const Line &m){
    if(isParallel(l,m))return distance(l,m.p1);
    return 0.0;
}

D distance(const Segment &s,const 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 distance(Line(s.p1,s.p2),p);

}

D distance(const Segment &s1,const Segment &s2){
    if(intersect(s1,s2))return 0.0;
    return min(min(distance(s1,s2.p1),distance(s1,s2.p2)),
               min(distance(s2,s1.p1),distance(s2,s1.p2)));
}

D area(const Polygon &g){
    D res=0.0;
    for(int i=0;i<g.size();i++){
        res+=cross(g[i],g[(i+1)%g.size()]);
    }
    return res/2.0;
}

Polygon andrewScan(Polygon g){
    Polygon u,l;
    if(g.size()<3)return g;
    sort(g.begin(),g.end());
    u.push_back(g[0]);
    u.push_back(g[1]);

    l.push_back(g[g.size()-1]);
    l.push_back(g[g.size()-2]);

    for(int i=2;i<g.size();i++){
        for(int n=u.size();n>=2&&ccw(u[n-2],u[n-1],g[i])!=CLOCKWISE;n--)u.pop_back();
        u.push_back(g[i]);
    }

    for(int i=g.size()-3;i>=0;i--){
        for(int n=l.size();n>=2&&ccw(l[n-2],l[n-1],g[i])!=CLOCKWISE;n--)l.pop_back();
        l.push_back(g[i]);
    }

    reverse(l.begin(),l.end());
    for(int i=u.size()-2;i>=1;i--)l.push_back(u[i]);
    return l;
}

bool isConvex(const Polygon &g){
    for(int i=0;i<g.size();i++){
        if(ccw(g[(i-1+g.size())%g.size()],g[i],g[(i+1)%g.size()])==CLOCKWISE)return false;
    }
    return true;
}

const int IN=2;
const int ON=1;
const int OUT=0;
int contains(const Polygon &g,const Point &p){
    int n=g.size();
    bool x=false;
    for(int i=0;i<n;i++){
        Point a=g[i]-p,b=g[(i+1)%n]-p;
        if(abs(cross(a,b))<EPS&&dot(a,b)<EPS)return ON;
        if(imag(a)>imag(b))swap(a,b);
        if(imag(a)<EPS&&EPS<imag(b)&&cross(a,b)>EPS)x=!x;
    }
    return (x?IN:OUT);
}

int main(){
    int N;cin>>N;
    Polygon g(N);for(int i=0;i<N;i++)cin>>g[i];

    int Q;cin>>Q;
    while(Q--){
        Point p;
        cin>>p;
        cout<<contains(g,p)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3316