#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#define EPS (1e-10)
using namespace std;
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;
class Point{
public:
    double x,y;
    Point(double x=0, double y=0):x(x),y(y){}
    Point operator +(const Point &p){
        return Point(x+p.x,y+p.y);
    }
    Point operator -(const Point &p){
        return Point(x-p.x,y-p.y);
    }
    Point operator *(double k){
        return Point(k*x,k*y);
    }
    Point operator /(double k){
        return Point(x/k,y/k);
    }

    double norm(){
        return x*x+y*y;
    }
    double abs(){
        return sqrt(norm());
    }
};
typedef Point Vector;
vector<Point>g;
struct segment{
    Point p1,p2;
};
typedef segment Line;
class Circle{
public:
    Point c;
    double r;
    Circle (double x=0, double y=0,double r=0):c(x,y),r(r){}
};
double dot(const Vector &v1,const Vector &v2){
    return v1.x*v2.x+v1.y*v2.y;
}
double cross(const Vector &v1,const Vector &v2){
    return v1.x*v2.y-v1.y*v2.x;
}
bool isParallel(const Vector &v1,const Vector &v2){
    if(fabs(cross(v1,v2)-0.0)<EPS)return true;
    return false;
}
bool isOrthogonal(const Vector &v1,const Vector &v2){
    if(fabs(dot(v1,v2)-0.0)<EPS)return true;
    return false;
}
Point projection( Point &p, Point &p1, Point &p2){
    Vector a=p-p1;
    Vector b=p2-p1;
    double r=dot(a,b);
    double pro_abs=r/b.norm();
    Vector res=b*pro_abs;
    return Point(res.x+p1.x,res.y+p1.y);
}
Point reflection(Point &p, Point &p1, Point &p2){
    Point pro=projection(p,p1,p2);
    Vector v=pro-p;
    v=v*2;
    return Point(v.x+p.x,v.y+p.y);
}
int ccw(Point &p, Point &p1, Point &p2){
    Vector a=p-p1;
    Vector b=p2-p1;
    if(cross(a,b)>0)return COUNTER_CLOCKWISE;
    if(cross(a,b)<0)return CLOCKWISE;
    if(dot(a,b)<0)return ONLINE_BACK;
    if(a.norm()>b.norm())return ONLINE_FRONT;
    return ON_SEGMENT;
}
bool intersect(segment &s1,segment &s2){
    if(ccw(s1.p1,s2.p1,s2.p2)*ccw(s1.p2,s2.p1,s2.p2)<=0 && ccw(s2.p1,s1.p1,s1.p2)*ccw(s2.p2,s1.p1,s1.p2)<=0)
        return true;
    return false;
}
double getDistanceSP(Point &p,segment &s){
    if(dot(p-s.p1,s.p2-s.p1)<0)return (p-s.p1).abs();
    if(dot(p-s.p2,s.p1-s.p2)<0)return (p-s.p2).abs();
    return fabs(cross(p-s.p1,s.p2-s.p1)/(s.p2-s.p1).abs());
}
double Distance(segment &s1,segment &s2){
    if(intersect(s1,s2))return 0;
    return min(min(getDistanceSP(s1.p1,s2),getDistanceSP(s1.p2,s2)),min(getDistanceSP(s2.p1,s1),getDistanceSP(s2.p2,s1)));
}
Point CrossPoint(segment &s1,segment &s2){
    Vector base =s2.p2-s2.p1;
    double d1=fabs(cross(base,s1.p1-s2.p1));
    double d2=fabs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return (s1.p2-s1.p1)*t+s1.p1;
}
pair<Point,Point> getCrossPoints(Circle &c,Line &l){
    Vector e = (l.p2-l.p1)/(l.p2-l.p1).abs();
    Point p=projection(c.c,l.p1,l.p2);
    double len=sqrt(c.r*c.r-(p-c.c).norm());
    return make_pair(p-e*len,p+e*len);
 }
pair<Point,Point> getCrossPoints(Circle &c1,Circle &c2){
    double d=(c1.c-c2.c).abs();
    double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    double t=atan2((c2.c-c1.c).y,(c2.c-c1.c).x);
    Point p1(c1.r*cos(t+a),c1.r*sin(t+a));
    Point p2(c1.r*cos(t-a),c1.r*sin(t-a));
    return make_pair(c1.c+p1,c1.c+p2);
}
//点的内包
int PPC(Point &p){
    int n=g.size();
    bool x=false;
    for(int i=0;i<n;i++)
    {
        Vector a=g[i]-p;
        Vector b=g[(i+1)%n]-p;
        if(fabs(cross(a,b)-0)<EPS && dot(a,b)<=0)return 1;
        if(a.y>b.y)swap(a,b);
        if(a.y<EPS && 0<b.y && cross(a,b)>0)x=!x;
    }
    return x?2:0;
}
int main()
{
    int n,q,x,y;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        Point p(x,y);
        g.push_back(p);
    }
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>x>>y;
        Point p(x,y);
        cout<<PPC(p)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3124