#include <bits/stdc++.h>
using namespace std;

struct F {
	long long a, b;
	F() {}
	F(long long _a, long long _b) : a(_a), b(_b) {}
	F operator + (const F &f) {
		long long x = a * f.a, y = b * f.a + a * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator - (const F &f) {
		long long x = a * f.a, y = b * f.a - a * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator * (const F &f) {
		long long x = a * f.a, y = b * f.b;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
	F operator / (const F &f) {
		long long x = a * f.b, y = b * f.a;
		long long g = __gcd(x, y);
		return F(x / g, y / g);
	}
};
const double pi = acos(-1);
const double eps = 1e-8;
inline int sign(double a) {
	return a < -eps ? -1 : a > eps;
}
inline int cmp(double a, double b) {
	return sign(a - b);
}
double add(double a, double b) {
	if (abs(a + b) < eps * (abs(a) + abs(b))) return 0;
	return a + b;
}
typedef double data;
struct P {
	data x, y;
	P() {}
	P(data x, data y) : x(x), y(y) {}
	P operator + (const P &p) { return P(x + p.x, y + p.y); }
	P operator - (const P &p) { return P(x - p.x, y - p.y); }
	P operator * (data d) { return P(x * d, y * d); }
	P operator / (data d) { return P(x / d, y / d); }
	data dot(const P &p) { return x * p.x + y * p.y; }
	data det(const P &p) { return x * p.y - y * p.x; }
	data disto(const P &p) { return (*this - p).abs(); }
	data alpha() { return atan2(y, x); }
	data abs() { return sqrt(abs2()); }
	data abs2() { return x * x + y * y; }
	P rot90() { P(-y, x); }
	P unit() { return *this / abs(); }
	bool operator < (P p) const {
		int c = cmp(x, p.x);
		if (c) return c == -1;
		return cmp(y, p.y) == -1;
	}
	friend istream& operator>>(istream &in, P &p) {
		in >> p.x >> p.y;
		return in;
	}
	friend ostream& operator<<(ostream& out, P &p) {
		out << p.x << ' ' << p.y;
		return out;
	}
};
P projection(P p1, P p2, P q) {
	P dir = p2 - p1;
	return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}
P reflection(P p1, P p2, P q) {
	return projection(p1, p2, q) * 2 - q;
}
bool is_midddle(data a, data m, data b) {
	return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
bool is_midddle(P a, P m, P b) {
	return is_midddle(a.x, m.x, b.x) && is_midddle(a.y, m.y, b.y);
}
bool on_seg(P p1, P p2, P q) {
	return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
	// return (p1 - q).det(p2 - q) == 0 && is_middle(p1, q, p2);
}
bool intersect(data l1, data r1, data l2, data r2) {
	if(l1 > r1) swap(l1, r1);
	if(l2 > r2) swap(l2, r2);
	return cmp(r1, l2) != -1 && cmp(r2, l1) != -1;
}
bool intersect(P p1, P p2, P q1, P q2) {
	return intersect(p1.x, p2.x, q1.x, q2.x) && intersect(p1.y, p2.y, q1.y, q2.y)
	&& sign((p2 - p1).det(q1 - p1)) * sign((p2 - p1).det(q2 - p1)) <= 0
	&& sign((q2 - q1).det(p1 - q1)) * sign((q2 - q1).det(q2 - q1)) <= 0;
}
P intersection(P p1, P p2, P q1, P q2) {
	data a1 = (q2 - q1).det(p1 - q1), a2 = -(q2 - p1).det(p2 - q1);
	return (p1 * a2 + p2 * a1) / (a1 + a2);
	//line return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}
data nearest(P p1, P p2, P q) {
	P h = projection(p1, p2, q);
	if(is_midddle(p1, h, p2)) return q.disto(h);
	return min(p1.disto(q), p2.disto(q));
}
data seg_dist(P p1, P p2, P q1, P q2) {
	if(intersect(p1, p2, q1, q2)) return 0;
	return min(min(nearest(p1, p2, q1), nearest(p1, p2, q2)), min(nearest(q1, q2, p1), nearest(q1, q2, p2)));
}
data area(vector<P> &ps) {
	data res = 0;
	int n = ps.size();
	for(int i = 0; i < n; i++) {
		res += ps[i].det(ps[(i + 1) % n]);
	}
	return abs(res / 2);
}
bool is_convex(vector<P> &ps) {
	int n = ps.size();
	for(int i = 0; i < n; i++) {
		data a1 = (ps[(i + 1) % n] - ps[i]).det(ps[(i + 2) % n] - ps[(i + 1) % n]);
		data a2 = (ps[(i + 2) % n] - ps[(i + 1) % n]).det(ps[(i + 3) % n] - ps[(i + 2) % n]);
		if(a1 * a2 < 0) {
			return false;
		}
	}
	return true;
}
int contain(vector<P> &ps, P p) {
	int n = ps.size(), res = 0;
	for(int i = 0; i < n; i++) {
		P u = ps[i], v = ps[(i + 1) % n];
		if(on_seg(u, v, p)) return 1;
		if(cmp(u.y, v.y) <= 0) swap(u, v);
		if(cmp(p.y, u.y) > 0 || cmp(p.y, v.y) <= 0) continue;
		res ^= (u - p).det(v - p) > 0;
	}
	return res * 2;
	//2:inside 1:on_seg 0:outside
}

int main() {
#ifdef LOCAL_DEFINE
	//freopen("data.in", "rt", stdin);
	//freopen("data.out", "w", stdout);
	auto _start = chrono::high_resolution_clock::now();
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(1);
	int n;
	cin >> n;
	vector<P> ps(n);
	for(int i = 0; i < n; i++) {
		cin >> ps[i];
	}
	int q;
	cin >> q;
	while(q--) {
		P t;
		cin >> t;
		cout << contain(ps, t) << '\n';
	}

#ifdef LOCAL_DEFINE
	auto _end = chrono::high_resolution_clock::now();
	cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}


Measured memory_bytes: 3300