import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}


immutable real EPS = 1e-7;

struct Point {
    real x, y;
    Point opBinary(string op)(in Point p) const if (op == "+" || op == "-") {
        return Point(mixin("x" ~ op ~ "p.x"), mixin("y" ~ op ~ "p.y"));
    }
    Point opBinary(string op)(real k) const if (op == "*" || op == "/") {
        return Point(mixin("x" ~ op ~ "k"), mixin("y" ~ op ~ "k"));
    }
};
real dot(in Point a, in Point b) { return a.x * b.x + a.y * b.y; }
real cross(in Point a, in Point b) { return a.x * b.y - a.y * b.x; }
real norm(in Point a) { return sqrt(dot(a, a)); }
Point rot90(in Point p) { return Point(-p.y, p.x); }
real angle(in Point a) { return atan2(a.y, a.x); }

const int CW = -1;
const int CCW = 1;
int ccw(Point a, Point b, Point c){
    b = b - a; c = c - a;                                          
    if (cross(b, c) > EPS) return +1;      // a,b,c????????????????¨???¨???
    if (cross(b, c) < -EPS) return -1;     // a,b,c?????????????¨???¨???                       
    if (dot(b, c) < 0) return +2;          // c--a--b ??´???                       
    if (norm(b) < norm(c)) return -2;      // a--b--c ??´???                       
    return 0;                              // a--c--b ??´???
}

struct Segment {
    Point a, b;
};
bool contains(in Segment s, in Point p) {
    return ccw(s.a, s.b, p) == 0;
}

class Polygon {
    Point[] vs;
    this(in Point[] vs) {
        this.vs = vs.dup;
    }
    override string toString() const { return vs.to!string; }
}
class convexPolygon : Polygon {
    this(in Point[] vs) { super(vs); }
}
bool contains(in convexPolygon polygon, in Point p) { // ?????????p???????????´????????????
    int N = cast(int)polygon.vs.length;
    int prev(int i) { return (i + N - 1) % N; }
    int next(int i) { return (i + 1) % N; }
    foreach (i; 0 .. N) {
        int c = ccw(p, polygon.vs[i], polygon.vs[next(i)]);
        if (c <= 0) return false;
    }
    return true;

}
convexPolygon[] triangleDivision(in Polygon p) {
    auto vs = p.vs.dup;
    convexPolygon[] ret;
    while (vs.length >= 3) {
        int N = cast(int)vs.length;
        int prev(int i) { return (i + N - 1) % N; }
        int next(int i) { return (i + 1) % N; }
        foreach (int i; 0 .. N) {
            if (ccw(vs[prev(i)], vs[i], vs[next(i)]) == CCW) {
                ret ~= new convexPolygon([ vs[prev(i)], vs[i], vs[next(i)] ]);
                vs = (i == N - 1 ? vs[0 .. $ - 1] : vs[0 .. i] ~ vs[i + 1 .. $]);
                break;
            }
        }
    }
    return ret;
}

void main() {
    int N; readf("%d\n", &N);
    auto vs = new Point[N];
    foreach (ref v; vs) {
        readf("%s %s\n", &v.x, &v.y);
    }
    const ts = triangleDivision(new Polygon(vs));
    int Q; readf("%d\n", &Q);
    foreach (q; 0 .. Q) {
        Point p; readf("%s %s\n", &p.x, &p.y);
        int f() {
            foreach (i, v; vs) {
                if (Segment(v, vs[(i + 1) % N]).contains(p)) return 1;
            }
            foreach (t; ts) {
                if (t.contains(p)) {
                    return 2;
                }
            }
            return 0;
        }
        writeln(f());
    }
}