#include<iostream>
#include<iomanip>
#include<algorithm>
#include<fstream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#define EPS (1e-5)
#define equals(a, b) (fabs((a) - (b)) < EPS )
//#define cout fout
//#define cin fin
#define CCW 1
#define YCW -1
#define ONB 3
#define ONF 4
#define ONS 0
#define IN 2
#define ON 1
#define OUT 0
using namespace std;

class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator + (Point p) {
		return Point(x + p.x, y + p.y); 
	}
	Point operator - (Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator * (double a) {
		return Point(a * x, a * y);
	}
	Point operator / (double a) {
		return Point(x / a, y / a);
	}

	double abs() {
		return sqrt(norm());
	}
	double norm() {
		return x * x + y * y;
	}

	bool operator < (const Point &p)const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p)const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0):c(c), r(r){}
};

typedef std::vector<Point> Polygon;
typedef Point Vector;

#ifdef cin
ifstream fin("CGL_1_C-in29.txt");
#endif

#ifdef cout
ofstream fout("out.txt");
#endif

double dot(Vector a, Vector b);
double cross(Vector a, Vector b);
double getDistanceSP(Point p, Point p1, Point p2);
double angle(Vector a, Vector b);
bool doIntersect(Point p1, Point p2, Point p3, Point p4);
double getDistanceSS(Point p1, Point p2, Point p3, Point p4);
int clockwise(Point p0, Point p1, Point p2);
Point crossPoint(Point p1, Point p2, Point p3, Point p4);
pair<Point, Point> crossPoint(Point p1, Point p2, Point center, double r);
Vector rotateVector(Vector v, double angle); //rad
Point project(Point p, Point p1, Point p2);
pair<Point, Point> crossPointsCC(Circle c1, Circle c2);
int doesContain(Polygon g, Point p);

int main() {
    int i, n, q, x, y, tmpx, tmpy;
	Polygon g;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> tmpx >> tmpy;
		Point tmpp(tmpx, tmpy);
		g.push_back(tmpp);
	}
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> x >> y;
		Point p(x, y);
		cout << doesContain(g, p) << endl;
	}
	
#ifdef cin
	fin.close();
#endif

#ifdef cout
	fout.close();
#endif
	return 0;
}

double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

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

double getDistanceSP(Point p, Point p1, Point p2) {
	if (dot(p - p1, p2 - p1) < 0.0)return (p - p1).abs();
	else if (dot(p - p2, p1 - p2) < 0.0)return (p - p2).abs();
	else return  fabs(cross(p2 - p1, p - p1)) / (p2 - p1).abs();
}


double angle(Vector a, Vector b) {
	if (equals(dot(a, b), a.abs() * b.abs()))return 0.0;
	else if (equals(dot(a, b), (-1) * a.abs() * b.abs()))return M_PI;
	if (cross(a, b) > 0.0)return acos(dot(a, b) / a.abs() / b.abs());
	else return (-1) * acos(dot(a, b) / a.abs() / b.abs());
}

bool doIntersect(Point p1, Point p2, Point p3, Point p4) {
	if (clockwise(p1, p2, p3) *  clockwise(p1, p2, p4) * clockwise(p3, p4, p1) * clockwise(p3, p4, p1) == 0) {
		return true;
	} else if (-1 <= clockwise(p1, p2, p3) * clockwise(p1, p2, p4) && clockwise(p1, p2, p3) * clockwise(p1, p2, p4) <= 0 && -1 <= clockwise(p3, p4, p1) * clockwise(p3, p4, p2) && clockwise(p3, p4, p1) * clockwise(p3, p4, p2) <= 0) {
		return true;
	} else {
		return false;
	}
}

double getDistanceSS(Point p1, Point p2, Point p3, Point p4) {
	if (doIntersect(p1, p2, p3, p4))return 0;
	else return min({ getDistanceSP(p4, p1, p2), getDistanceSP(p3, p1, p2), getDistanceSP(p1, p3, p4), getDistanceSP(p2, p3, p4) });
}

int clockwise(Point p0, Point p1, Point p2) {
	if (p2 == p0 || p2 == p1) {
		//cout << "ON_SEGMENT" << endl;
		return ONS;
	} else if (angle(p1 - p0, p2 - p0) == 0.0) {
		if ((p1 - p0).norm() < (p2 - p0).norm()) {
			//cout << "ONLINE_FRONT" << endl;
			return ONF;
		} else {
			//cout << "ON_SEGMENT" << endl;
			return ONS;
		}
	} else if(angle(p1 - p0, p2 - p0) == M_PI){
		//cout << "ONLINE_BACK" << endl;
		return ONB;
	} else {
		if (angle(p1 - p0, p2 - p0) > 0.0) {
			//cout << "COUNTER_CLOCKWISE" << endl;
			return CCW;
		} else {
			//cout << "CLOCKWISE" << endl;
			return YCW;
		}
	}
}

Point crossPoint(Point p1, Point p2, Point p3, Point p4) {
	double d1, d2, t;
	d1 = fabs(cross(p2 - p1, p3 - p1) / (p2 - p1).norm());
	d2 = fabs(cross(p2 - p1, p4 - p1) / (p2 - p1).norm());
	t = d1 / (d1 + d2);
	return (p3 + (p4 - p3) * t);
}

pair<Point, Point> crossPoint(Point p1, Point p2, Point center, double r) {
	Vector pr = project(center, p1, p2) - center;
	double base = sqrt(r * r - pr.norm());

	Vector ans1 = center + pr + (p2 - p1) / (p2 - p1).abs() * base;
	Vector ans2 = center + pr - (p2 - p1) / (p2 - p1).abs() * base;
	
	if (ans1 < ans2) {
		return make_pair(ans1, ans2);
	} else {
		return make_pair(ans2, ans1);
	}

}

Vector rotateVector(Vector v, double angle) {
	Vector ans(v.x * cos(angle) - v.y * sin(angle), v.x * sin(angle) + v.y * cos(angle));
	return ans;
}

Point project(Point p, Point p1, Point p2) {
	Vector hypo = p - p1, base = p2 - p1;
	return (p1 + base * dot(hypo, base) / base.norm());
}

pair<Point, Point> crossPointsCC(Circle c1, Circle c2) {
	double d = (c2.c - c1.c).abs();
	double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
	Point ans1 = c1.c + rotateVector(c2.c - c1.c, a) / d * c1.r, ans2 = c1.c + rotateVector(c2.c - c1.c, (-1) * a) / d * c1.r;
	if (ans1 < ans2) {
		return make_pair(ans1, ans2);
	} else {
		return make_pair(ans2, ans1);
	}
}

int doesContain(Polygon g, 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(fabs(cross(a, b)) < EPS && dot(a, b) < EPS) {
			return ON;
		}
		if (a.y > b.y) {
			Point tmpp = a;
			a = b;
			b = tmpp;
		}
		if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) {
			x = !x;
		}
	}
	return (x ? 2 : 0);

}

Measured memory_bytes: 3108