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

//?????????
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //???????????????????????????????????????????????????
std::ifstream ifs("data.txt");
#define put ifs >>
#else //?????£????????????????????§?????????????????????
#define put cin >>
#endif
#pragma endregion

//???????????°??????????????´
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef????????????????????????????¶????????????§?????????
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//??????????????°(???????????????????????§??????)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e9)
#pragma endregion

//?????????????????????
#pragma region Geometry
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(x * a, y * a); }
	double operator * (Point p) { return dot(p); }
	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; }
	//???????????????
	double dot(Point p) { return x * p.x + y * p.y; }
	double cross(Point p) { return x * p.y - y * p.x; }


};
class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};
struct Segment {//??????
	Point p1, p2;
};
typedef Point Vector;
typedef Segment Line;//??´???
typedef vector<Point> Polygon; //????§???¢?????????

//?????????????¨????
double v_norm(Point p) { return p.x * p.x + p.y * p.y; }
double abs(Point p) { return sqrt(v_norm(p)); }
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } //??????
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }//??????

//??´????????????
bool isOrthogonal(Vector a, Vector b) { return equals(a*b, 0.0); }
bool isParallel(Vector a, Vector b) { return equals(cross(a, b), 0.0); }

//??????s???????????????p????°???±
Point projection(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(( p - s.p1 ), base) / v_norm(base);
	return s.p1 + base*r;
}
//??????s???????????????p???????°?
Point reflection(Segment s, Point p) { return p + ( projection(s, p) - p ) * 2; }

//3??????????????¢????????????
//p1-p0???????????¨?????? p2-p0 ???2????????????????????????
static const int COUNTER_CLOCKWISE = 1;//???????¨???????
static const int CLOCKWISE = -1;//????¨???????
static const int ONLINE_BACK = 2;//????????´?????¶p2,p0,p1??????
static const int ONLINE_FRONT = -2;//????????´??????p0,p1,p2??????
static const int ON_SEGMENT = 0;//p2???p0,p1??????????????´???
int ccw(Point p0, Point p1, Point p2) {//????¨????????????¢??°
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS) return CLOCKWISE;
	if (dot(a, b) < -EPS) return ONLINE_BACK;
	if (a.norm() < b.norm()) return ONLINE_FRONT;
	return ON_SEGMENT;
}

//??????p1p2??¨p3p4???????????????
bool intersect(Point p1, Point p2, Point p3, Point p4) {return ( (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0) && (ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0));}
bool intersect(Segment s1, Segment s2) {return intersect(s1.p1 , s1.p2, s2.p1, s2.p2);}

//?????¢ Segment Line Point
double getDistance(Point a, Point b) { return abs( a - b ); }
double getDistanceLP(Line l, Point p) {return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));}
double getDistanceSP(Segment s, Point p) {
	dbg(abs(p - s.p1));
	dbg(abs(p - s.p2));
	if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1);
	if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2);
	return getDistanceLP(s, p);
}
double getDistance(Segment s1, Segment s2) {
	if (intersect(s1, s2)) return 0.0;
	dbg2(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2));	
	dbg2(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2));
	return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2))
	         , min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)));
}

//2???????????????
Point getCrossPoint(Segment s1, Segment s2) {
	Vector base = s2.p2 - s2.p1;
	double d1 = abs(cross(base , s1.p1 - s2.p1));
	double d2 = abs(cross(base , s1.p2 - s2.p1));
	double t = d1 / ( d1 + d2 );
	return s1.p1 + (s1.p2 - s1.p1 ) * t;
}

//??´?????¨????????????????????????
pair<Point, Point> getCrossPoints(Circle c, Line l) {
	//assert(intersect(c, i)); ?????????????????´????????????????????????
	Vector pr = projection(l , c.c);
	Vector e = ( l.p2 - l.p1 ) / abs(l.p2 - l.p1);
	double base = sqrt(c.r * c.r - (pr - c.c).norm());
	return mp(pr + e * base, pr - e * base);
}

//????????????????????????
//poly ??????????¨?????????????????????¶
static const int IN_POLYGON = 2;//????§???¢????????¨
static const int OUT_POLYGON = 1;//????§???¢????????¨
static const int ON_POLYGON = 0;//????§???¢????????????
int contains(Polygon g, Point p) {
	int n = g.size();
	bool x = false;
	rep(i, n) {
		Point a = g[i] - p, b = g[( i + 1 ) % n] - p;
		if (abs(cross(a, b)) < EPS && dot(a, b) < EPS) return OUT_POLYGON;
		if (a.y > b.y) swap(a, b);
		if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) x = !x;
	}
	return ( x ? IN_POLYGON : ON_POLYGON );
}

//?????? CGL_4_A : Convex Hull; 
//containsPointOnline ?????????????????????????????????????????????
//???????§???¢???????????§????????????????????????????????§???????????????????????????????????§???
//???????¨???¨?????§???????????§?¨?????????????
Polygon ConvexHull(Polygon s, bool containsPointOnline = false) {
	Polygon u, l;
	if (s.size() <= 3) return s;
	sort(s.begin(), s.end());
	u.push_back(s[0]); 
	u.push_back(s[1]);
	l.push_back(s[s.size() - 1]);
	l.push_back(s[s.size() - 2]);
	auto conditionContaining = [](int ccw, bool containsPointOnline)->bool{
		if (containsPointOnline) return ccw == COUNTER_CLOCKWISE;
		else return ccw != CLOCKWISE;
	};
	for (int i = 2; i < s.size(); i++) {//?????´?????°???
		for (int n = u.size(); ( n >= 2 ) && conditionContaining( ccw(u[n - 2], u[n - 1], s[i]),containsPointOnline); n--) {
			u.pop_back();
		}
		u.push_back(s[i]);
	}
	for (int i = s.size() - 3; i >= 0; i--) {//?????´?????°???
		for (int n = l.size(); n >= 2 && conditionContaining( ccw(l[n - 2], l[n - 1], s[i]),containsPointOnline); n--)l.pop_back();
		l.push_back(s[i]);
	}
	reverse(l.begin(), l.end());
	for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);
	double tmpMax = l[0].y;
	int rotIndex = 0;
	REP(i,1,l.size()) {//?????¶??????????????????????????????????????´??????
		if (l[i].y < tmpMax) {
			rotIndex = i;
			tmpMax = l[i].y;
		}
	}
	rotate(l.begin(), l.begin() + rotIndex, l.end());
	return l;
}
#pragma endregion 

//?????§????????£????????????????????? ????????????????§????180?°??\???
bool isConvex(Polygon poly) {
	Polygon conv = ConvexHull(poly,true);
	return conv.size() == poly.size();
}

//??????????£?????????°???
//https://www23.atwiki.jp/akitaicpc/pages/65.html

int main() {
	int n; put n;
	Polygon poly;
	rep(i, n) {
		Point p;
		put p.x >> p.y;
		poly.push_back(p);
	}
	int q; put q;
	rep(i, q) {
		Point p; put p.x >> p.y;
		cout << contains(poly,p) << endl;
	}

END:
	return 0;
}
/*
	int q; put q;
	rep(i, q) {
		Point p[4];
		rep(j, 4) {
			put p[j].x >> p[j].y;
		}
		Segment s0, s1;
		s0.p1 = p[0];
		s0.p2 = p[1];
		s1.p1 = p[2];
		s1.p2 = p[3];
		double dist = getDistance(s0,s1);
		dputans(dist);
	}
	*/

	//int n; put n;
	//Polygon p;
	//rep(i, n) {
	//	double x, y; put x >> y;
	//	p.push_back(Point(x, y));
	//}
	//Polygon k = ConvexHull(p,true);
	//cout << k.size() << endl;
	//rep(i, k.size()) {
	//	cout << k[i].x << " " << k[i].y << endl;
	//}	

	/*double xp1, yp1, xp2, yp2; put xp1 >> yp1 >> xp2 >> yp2;
	Segment s;
	s.p1 = Point(xp1, yp1);
	s.p2 = Point(xp2, yp2);

	int n; put n;
	rep(i, n) {
		Point p;
		put p.x >> p.y;
		Point prj =reflection(s, p);
		cout << setprecision(13) << prj.x << " " << prj.y << endl;
	}*/

	//ll ans = 0;
	//int n; put n;
	//vi a;
	//set<Range> rl;
	//rep(i, n) {
	//	int k; put k;
	//	a.push_back(k);
	//}
	//reverse(a.begin(), a.end());
	//int miner = a[0];
	//ans += miner;
	//REP(i,1,n) {
	//	if (a[i] < miner) {
	//		miner = a[i];
	//		ans += miner * ( i + 1 );
	//	}
	//	else {
	//		ans += miner *(i)+a[i];
	//	}
	//}

	////???????????¬??????????????\???????????????
	//auto getI = [&]()->auto { int tmp; put tmp; return tmp; };
	//auto getLL = [&]()->auto { ll tmp; put tmp; return tmp; };
	//auto getS = [&]()->auto { string tmp; put tmp; return tmp; };
//
//int n, a, b; put n >> a >> b;
//	vi t;
//	rep(i, n) {
//		t.push_back(get());
//	}
//	int count = 0;
//	rep(i, n) {
//		if (t[i] < a || b <= t[i])count++;
//	}
//	putans(count);

//
//	set<string> list;
//	int ans = 0;
//	int n; put n;
//	int k; put k;
//	int numAlphabet[26];
//	fill(all(numAlphabet), 0);
//	rep(i, n) {
//		string s; put s;
//		if (exist(list, s))continue;
//		list.insert(s);
//		numAlphabet[s[0] - 'A']++;
//	}
//	sort(all(numAlphabet),greater<int>());
//	while (true) {
//		rep(i, k) {
//			if (numAlphabet[i] == 0) goto END;
//			else numAlphabet[i]--;
//		}
//		sort(all(numAlphabet), greater<int>());
//		ans++;
//	}
//END:
//	putans(ans);


	//int t; put t;
	//rep(i, t) {
	//	int n, d; put n >> d;
	//	if (n == 1) {
	//		putans(d);
	//		continue;
	//	}
	//	putans(n % 2 != 0 ? ( n - 1 ) * 127 + d : ( n - 1 ) * 127 + ( 127 ^ d ));
	//}


//
//int n; put n;
//string s1, s2;
//string r;
//string patan1[4] = { ".","#",".","#" };
//string patan2[4] = { ".",".","#","#" };
//bool front = true;
//rep(j, 420 / 4) {
//	if (front) {
//		rep(i, 4) {
//			cout << s1 + patan1[i] + "\n" << s2 + patan2[i] << endl;
//			cin >> r;
//			if (r == "T") {
//				s1 += patan1[i];
//				s2 += patan2[i];
//				break;
//			}
//			if (r == "F" && i == 3) {
//				front = !front;
//			}
//			if (r == "end")goto END;
//		}
//	}
//	else {
//		rep(i, 4) {
//			cout << patan1[i] + s1 + "\n" << patan2[i] + s2 << endl;
//			cin >> r;
//			if (r == "T") {
//				s1 = patan1[i] + s1;
//				s2 = patan2[i] + s2;
//				break;
//			}
//			if (r == "F" && i == 3) {
//				front = !front;
//			}
//			if (r == "end")goto END;
//		}
//	}
//
//}
//END:
//cout << endl;




	//bool filled[1000][1000];
	//fill(*filled, *filled + 1000 * 1000, false);
	//int vx[4] = { 1,0,-1,0 };
	//int vy[4] = { 0,1,0,-1 };
	//Polygon sheep;
	//Polygon convex_sheep;
	//ll num = 0;
	//int h, w; put h >> w;
	//rep(i, h) {
	//	string s; put s;
	//	rep(j, s.size()) {
	//		if (s[j] == 'X') {
	//			if (i == 0 || j == 0 || i == h-1 || j == w-1) {
	//				putans(-1);
	//				goto END;
	//			}
	//			rep(k, 4) {
	//				if (!filled[i + vx[k]][j + vy[k]]) {
	//					sheep.push_back(Point(i + vx[k],j + vy[k]));
	//					filled[i + vx[k]][j + vy[k]] = true;
	//				}
	//			}
	//		}
	//	}
	//}
	//convex_sheep = ConvexHull(sheep);

	//rep(i, convex_sheep.size()) {
	//	Point s = convex_sheep[i % convex_sheep.size()];
	//	Point g = convex_sheep[(i + 1) % convex_sheep.size()];
	//	ll mandist = max(abs(s.x - g.x),abs(s.y - g.y));
	//	dbg(mandist);
	//	num += mandist;
	//} 
	//putans(num);

Measured memory_bytes: 3232