#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
const double EPS = 1e-8;
typedef pair<double, double> pt;
#define x first
#define y second
ostream& operator<<(ostream& os, const pt& p) {
    return os << p.x << " " << p.y;
}
typedef pair<pt, pt> seg;
#define a first
#define b second
pt operator-(pt a, pt b) {
  return pt(a.x - b.x, a.y - b.y);
}

bool zero(double x) {
  return fabs(x) <= EPS;
}

bool dequal(double x, double y) {
    return fabs(x-y) <= EPS;
}

double cross(pt a, pt b) {
  return a.x*b.y - a.y*b.x;
}

bool ccw(pt a, pt b, pt c) {
  return cross(b - a, c - a) >= 0;
}
bool collinear(seg a, seg b) { // all four points collinear
  return zero(cross(a.b - a.a, b.a - a.a)) &&
         zero(cross(a.b - a.a, b.b - a.a));
}

double sq(double a) { return a * a; }

double dist(pt p, pt q) {
  return sqrt(sq(p.x - q.x) + sq(p.y - q.y));
}

bool intersect(seg a, seg b) {
  if (collinear(a, b)) {
    double maxDist = 0;
    maxDist = max(maxDist, dist(a.a, a.b));
    maxDist = max(maxDist, dist(a.a, b.a));
    maxDist = max(maxDist, dist(a.a, b.b));
    maxDist = max(maxDist, dist(a.b, b.a));
    maxDist = max(maxDist, dist(a.b, b.b));
    maxDist = max(maxDist, dist(b.a, b.b));
    return maxDist < dist(a.a, a.b) + dist(b.a, b.b) + EPS;
  }
  return ccw(a.a, a.b, b.a) != ccw(a.a, a.b, b.b) &&
         ccw(b.a, b.b, a.a) != ccw(b.a, b.b, a.b);
}

bool pointOnLine(pt a, seg s) {
    if (a.x >= min(s.a.x, s.b.x) && a.x <= max(s.a.x, s.b.x)
        &&
        a.y >= min(s.a.y, s.b.y) && a.y <= max(s.a.y, s.b.y)) {
            if (dequal(s.a.x, s.b.x)) return true;

            const double M = (s.b.y - s.a.y) / (s.b.x - s.a.x);
            const double C = (-M * s.a.x) + s.a.y;

            return zero(a.y - (M*a.x+C));
    }
    return false;
}

int N, Q;
vector<pt> polypts;
vector<seg> poly;
int main() {
    cin >> N;
    for ( int p = 0; p < N; ++p) {
        int x, y;
        cin >> x >> y;
        polypts.push_back(pt(x, y));
        if (p > 0) {
            poly.push_back(seg(*(polypts.end()-2), polypts.back()));
            // cout << "created seg " << poly.back().a << " -> " << poly.back().b << endl;
        }        
    }
    poly.push_back(seg(polypts.back(), polypts.front()));
    // cout << "created seg " << poly.back().a << " -> " << poly.back().b << endl;

    cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int x ,y;
        cin >> x >> y;
        pt p = pt(x, y);
        seg ray = seg(pt(x,y), pt(11000, y));
        int counter = 0;
        bool done = false;
        for (seg s : poly) {
            if (pointOnLine(p, s)) {
                //cout << "point on polygon edge " << p << endl;
                cout << 1 << endl;
                done = true;
                break;
            }
            if (pointOnLine(s.a, ray)) {
                // cout << "seg point a on ray " << endl;
                if (s.b.y < p.y)
                    counter++;
                continue;
            }
            if (intersect(s, ray))
                counter++;
        }
        if (!done) {
            if (counter % 2 == 0) {
                cout << 0 << endl;
            } else {
                cout << 2 << endl;
            }
        }
        // cout << "intersects " << counter << endl;
        // if (counter == 0) {
        //     cout << 0 << endl;
        // }
    }
    return 0;
}
