#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

const double EPS = 1e-9;
const double PI = acos(-1);

int sign(double x) {
    if (fabs(x) < EPS) {
        return 0;
    } else if (x > 0) {
        return 1;
    } else {
        return -1;
    }
}

int dcmp(double x, double y) {
    return sign(x - y);
}

struct Vector;
typedef Vector Point;

struct Vector {
    double x;
    double y;

    explicit Vector(double x = 0, double y = 0);

    Vector operator+(const Vector &rhs) const;
    Vector operator-() const;
    Vector operator-(const Vector &rhs) const;
    Vector operator*(double d) const;
    Vector operator/(double d) const;
    double operator*(const Vector &rhs) const;
    double operator^(const Vector &rhs) const;

    bool operator==(const Vector &rhs) const;
    bool operator!=(const Vector &rhs) const;
    bool operator<(const Vector &rhs) const;
    bool operator>(const Vector &rhs) const;
    bool operator<=(const Vector &rhs) const;
    bool operator>=(const Vector &rhs) const;

    friend std::ostream &operator<<(std::ostream &os, const Vector &vector);

    double length() const;
    double angle() const;
    double getDistanceTo(const Point &rhs) const;

    static bool cmpByAngle(const Point &a, const Point &b);
};

struct Segment {
    Point a;
    Point b;

    explicit Segment(double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0);
    explicit Segment(const Point &a = Point(), const Point &b = Point());

    double length() const;
    bool contains(const Point &p, bool containsEndPoints = true) const;
    bool intersects(const Segment &rhs, bool containsEndPoints = true) const;
};

struct Polygon {
    std::vector<Point> points;

    enum class ContainsPoint {
        OUT,
        ONLINE,
        IN
    };

    explicit Polygon(const std::vector<Point> &points);

    ContainsPoint contains(const Point &p) const;
};

Vector::Vector(double x, double y) : x(x), y(y) {}

Vector Vector::operator+(const Vector &rhs) const {
    return Vector(x + rhs.x, y + rhs.y);
}

Vector Vector::operator-() const {
    return Vector(-x, -y);
}

Vector Vector::operator-(const Vector &rhs) const {
    return *this + -rhs;
}

Vector Vector::operator*(double d) const {
    return Vector(x * d, y * d);
}

Vector Vector::operator/(double d) const {
    return Vector(x / d, y / d);
}

double Vector::operator*(const Vector &rhs) const {
    return x * rhs.x + y * rhs.y;
}

double Vector::operator^(const Vector &rhs) const {
    return x * rhs.y - rhs.x * y;
}

bool Vector::operator==(const Vector &rhs) const {
    return dcmp(x, rhs.x) == 0 && dcmp(y, rhs.y) == 0;
}

bool Vector::operator!=(const Vector &rhs) const {
    return !(rhs == *this);
}

bool Vector::operator<(const Vector &rhs) const {
    if (dcmp(x, rhs.x) != 0) {
        return dcmp(x, rhs.x) < 0;
    } else {
        return dcmp(y, rhs.y) < 0;
    }
}

bool Vector::operator>(const Vector &rhs) const {
    return rhs < *this;
}

bool Vector::operator<=(const Vector &rhs) const {
    return !(rhs < *this);
}

bool Vector::operator>=(const Vector &rhs) const {
    return !(*this < rhs);
}

std::ostream &operator<<(std::ostream &os, const Vector &vector) {
    os << "(" << vector.x << ", " << vector.y << ")";
    return os;
}

double Vector::length() const {
    return sqrt(*this * *this);
}

double Vector::angle() const {
    return atan2(y, x);
}

double Vector::getDistanceTo(const Point &rhs) const {
    return sqrt(pow(x - rhs.x, 2) + pow(y - rhs.y, 2));
}

bool Vector::cmpByAngle(const Point &a, const Point &b) {
    return dcmp(a.angle(), b.angle()) < 0;
}

Segment::Segment(double x1, double y1, double x2, double y2) : a(x1, y1), b(x2, y2) {}

Segment::Segment(const Point &a, const Point &b) : a(a), b(b) {}

double Segment::length() const {
    return a.getDistanceTo(b);
}

bool Segment::contains(const Point &p, bool containsEndPoints) const {
    const Vector &u = a - p;
    const Vector &v = b - p;
    return sign(u ^ v) == 0 && (containsEndPoints ? sign(u * v) <= 0 : sign(u * v) < 0);
}

bool Segment::intersects(const Segment &rhs, bool containsEndPoints) const {
    const Vector &u = b - a;
    const Vector &v = rhs.b - rhs.a;
    double c1 = u ^(rhs.a - a);
    double c2 = u ^(rhs.b - a);
    double c3 = v ^(a - rhs.a);
    double c4 = v ^(b - rhs.a);
    if (containsEndPoints && (!sign(c1) || !sign(c2) || !sign(c3) || !sign(c4))) {
        return contains(rhs.a) || contains(rhs.b) || rhs.contains(a) || rhs.contains(b);
    }
    return sign(c1) * sign(c2) < 0 && sign(c3) * sign(c4) < 0;
}

Polygon::Polygon(const std::vector<Point> &points) : points(points) {}

Polygon::ContainsPoint Polygon::contains(const Point &p) const {
    Segment s0(p, p + Vector(1e10, 0));
    int sum = 0;
    for (int i = 0; i < points.size(); i++) {
        Point u = points[i];
        Point v = points[(i + 1) % points.size()];
        const Segment &s = Segment(u, v);
        if (s.contains(p)) {
            return ContainsPoint::ONLINE;
        }
        if (dcmp(u.y, v.y) <= 0) {
            std::swap(u, v);
        }
        if (dcmp(p.y, u.y) > 0 || dcmp(p.y, v.y) <= 0) {
            continue;
        }
        sum += s0.intersects(s) ? 1 : 0;
    }
    return (sum & 1) ? ContainsPoint::IN : ContainsPoint::OUT;
}


int main() {
//    freopen("data.in", "r", stdin);

    int n, q;
    while (~scanf("%d", &n)) {
        vector<Point> points;
        points.reserve(n);
        for (int i = 0; i < n; i++) {
            int x, y;
            scanf("%d%d", &x, &y);
            points.emplace_back(x, y);
        }

        Polygon polygon(points);

        scanf("%d", &q);
        while (q--) {
            int x, y;
            scanf("%d%d", &x, &y);
            switch (polygon.contains(Point(x, y))) {
                case Polygon::ContainsPoint::IN:{
                    puts("2");
                    break;
                }
                case Polygon::ContainsPoint::ONLINE: {
                    puts("1");
                    break;
                }
                case Polygon::ContainsPoint::OUT: {
                    puts("0");
                    break;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3152