#include <bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
	#include <boost/multiprecision/cpp_int.hpp>
	#include <boost/multiprecision/cpp_dec_float.hpp>
	using bll = boost::multiprecision::cpp_int;
	using bdouble = boost::multiprecision::cpp_dec_float_100;
#endif
*/
#ifdef LOCAL_DEV
	void debug_impl() { std::cerr << std::endl; }
	template<typename Head, typename... Tail> void debug_impl(Head head, Tail... tail) { std::cerr << " " << head << (sizeof...(tail) ? "," : ""); debug_impl(tail...); }
	#define debug(...) { std::cerr << std::boolalpha << "(" << #__VA_ARGS__ << ") ="; debug_impl(__VA_ARGS__); std::cerr << std::noboolalpha; }
#else
	#define debug(...) {}
#endif
#ifdef LOCAL_TEST
	#define BOOST_STACKTRACE_USE_ADDR2LINE
	#define BOOST_STACKTRACE_ADDR2LINE_LOCATION /usr/local/opt/binutils/bin/addr2line
	#define _GNU_SOURCE
	#include <boost/stacktrace.hpp>
	template<typename T> class dvector : public std::vector<T> {
	public:
		dvector() : std::vector<T>() {}
		explicit dvector(size_t n, const T& value = T()) : std::vector<T>(n, value) {}
		dvector(const std::vector<T>& v) : std::vector<T>(v) {}
		dvector(const std::initializer_list<T> il) : std::vector<T>(il) {}
		dvector(const typename std::vector<T>::iterator first, const typename std::vector<T>::iterator last) : std::vector<T>(first, last) {}
		dvector(const std::string::iterator first, const std::string::iterator last) : std::vector<T>(first, last) {}
		T& operator[](size_t n) {
			try { return this->at(n); } catch (const std::exception& e) {
				std::cerr << boost::stacktrace::stacktrace() << std::endl; return this->at(n);
			}
		}
		const T& operator[](size_t n) const {
			try { return this->at(n); } catch (const std::exception& e) {
				std::cerr << boost::stacktrace::stacktrace() << std::endl; return this->at(n);
			}
		}
	};
	class dbool {
	private:
		bool boolvalue;
	public:
		dbool() : boolvalue(false) {}
		dbool(bool b) : boolvalue(b) {}
		dbool(const dbool &b) : boolvalue(b.boolvalue) {}
		operator bool&() { return boolvalue; }
		operator const bool&() const { return boolvalue; }
	};
	template<typename T> std::ostream& operator<<(std::ostream& s, const dvector<T>& v) {
		for (int i = 0, len = v.size(); i < len; ++i){ s << v[i]; if (i < len - 1) s << "\t"; } return s; }
	template<typename T> std::ostream& operator<<(std::ostream& s, const dvector< dvector<T> >& vv) {
		for (int i = 0, len = vv.size(); i < len; ++i){ s << vv[i] << std::endl; } return s; }
	template<typename T> std::ostream& operator<<(std::ostream& s, const std::set<T>& se) {
		s << "{ "; for (auto itr = se.begin(); itr != se.end(); ++itr){ s << (*itr) << "\t"; } s << "}"; return s; }
	template<typename T> std::ostream& operator<<(std::ostream& s, const std::multiset<T>& se) {
		s << "{ "; for (auto itr = se.begin(); itr != se.end(); ++itr){ s << (*itr) << "\t"; } s << "}"; return s; }
	template<typename T1, typename T2> std::ostream& operator<<(std::ostream& s, const std::map<T1, T2>& m) {
		s << "{" << std::endl; for (auto itr = m.begin(); itr != m.end(); ++itr){ s << "\t" << (*itr).first << " : " << (*itr).second << std::endl; } s << "}"; return s; }
	template<typename T1, typename T2> std::ostream& operator<<(std::ostream& s, const std::pair<T1, T2>& p) { 
		return s << "(" << p.first << ", " << p.second << ")"; }
	#define vector dvector
	#define bool dbool
	class SIGFPE_exception : std::exception {};
	class SIGSEGV_exception : std::exception {};
	void catch_SIGFPE(int e) { std::cerr << boost::stacktrace::stacktrace() << std::endl; throw SIGFPE_exception();	}
	void catch_SIGSEGV(int e) { std::cerr << boost::stacktrace::stacktrace() << std::endl; throw SIGSEGV_exception(); }
	signed convertedmain();
	signed main() { signal(SIGFPE, catch_SIGFPE); signal(SIGSEGV, catch_SIGSEGV); return convertedmain(); }
	#define main() convertedmain()
#endif
//#define int long long
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define rrep(i, n)   for(ll i=(n)-1; i>=0; --i)
#define rrepeq(i, n) for(ll i=(n)  ; i>=1; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
void p() { std::cout << '\n'; }
template<typename Head, typename... Tail> void p(Head head, Tail... tail) { std::cout << head << (sizeof...(tail) ? " " : ""); p(tail...); }
template<typename T> inline void pv(vector<T> &v) { for(ll i=0, N=v.size(); i<N; i++) std::cout << v[i] << " \n"[i==N-1]; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T> inline bool chmax(T &a, T b) { return a < b && (a = b, true); }
template<typename T> inline bool chmin(T &a, T b) { return a > b && (a = b, true); }

/*-----8<-----template-----8<-----*/

//点、ベクトル
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 * (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 n) {return Point(x+n, y+n);}
	Point operator - (double n) {return Point(x-n, y-n);}
	Point operator * (double n) {return Point(x*n, y*n);}
	Point operator / (double n) {return Point(x/n, y/n);}

	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;
	}
	
};
using Vector = Point;

//線分、直線
class Segment {
public:
	Point p1,p2;
	Segment() {}
	Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
};
using Line = Segment;

//ベクトルの内積
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 equals(double a,double b){ return fabs(a-b)<EPS; }
//直交判定
bool isOrthogonal(Vector a,Vector b){
	return equals(dot(a,b), 0.0);
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
	return isOrthogonal(a1-a2, b1-b2);
}
bool isOrthogonal(Segment s1,Segment s2){
	return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}
//平行判定
bool isParallel(Vector a,Vector b){
	return equals(cross(a,b), 0.0);
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
	return isParallel(a1-a2, b1-b2);
}
bool isParallel(Segment s1,Segment s2){
	return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}
//射影
Point project(Segment s,Point p){
	Vector base = s.p2-s.p1;
	double r = dot(p-s.p1, base)/base.norm();
	return base*r + s.p1;
}
//反射
Point reflect(Segment s,Point p){
	return p + (project(s,p)-p)*2;
}

//p0,p1,p2が反時計回りになる
static const int COUNTER_CLOCKWISE = 1;
//p0,p1,p2が時計回りになる
static const int CLOCKWISE = -1;
//p2,p0,p1がこの順で同一直線状にある
static const int ONLINE_BACK = 2;
//p0,p1,p2がこの順で同一直線状にある
static const int ONLINE_FRONT = -2;
//p2が線分p0p1上にある
static const int ON_SEGMENT = 0;
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);
}

//二点間の距離
double getDistance(Point a,Point b){
	return (a-b).abs();
}
//点と直線の距離
double getDistanceLP(Line l,Point p){
	return fabs(cross(l.p2-l.p1, p-l.p1)) / (l.p2-l.p1).abs();
}
//点と線分の距離
double getDistanceSP(Segment s,Point p){
	if(dot(s.p2-s.p1, p-s.p1)<0.)return (p-s.p1).abs();
	if(dot(s.p1-s.p2, p-s.p2)<0.)return (p-s.p2).abs();
	return getDistanceLP(s,p);
}
//線分と線分の距離
double getDistance(Segment s1,Segment s2){
	if(intersect(s1,s2))return 0.;
	return min({getDistanceSP(s1,s2.p1), getDistanceSP(s1,s2.p2), getDistanceSP(s2,s1.p1), getDistanceSP(s2,s1.p2)});
}

//線分s1と線分s2の交点
Point getCrossPoint(Segment s1, Segment s2){
	Vector base = s2.p2-s2.p1;
	double d1=fabs(cross(base, s1.p1-s2.p1));
	double d2=fabs(cross(base, s1.p2-s2.p1));
	double t=d1/(d1+d2);
	return s1.p1+(s1.p2-s1.p1)*t;
}

//円
class Circle {
public:
	Point c;
	double r;
	//c:中心の点、r=半径
	Circle(Point c=Point(), double r=0.) : c(c), r(r) {}
};
////円cと線分lの交点の数を返す
int hasCrossPoints(Circle c, Line l){
	double dis = getDistanceLP(l,c.c);
	if(equals(dis,c.r))return 1;
	if(dis < c.r)return 2;
	return 0;
}
//円cと線分lの交点を返す
pair<Point,Point> getCrossPoints(Circle c, Line l){
	assert(getDistanceLP(l,c.c) < c.r+EPS);
	Vector pr=project(l, c.c);
	Vector e=(l.p2-l.p1)/(l.p2-l.p1).abs();
	double base=sqrt(c.r*c.r-(pr-c.c).norm());
	return {pr+e*base, pr-e*base};
}


//ベクトルpとx軸との角度を返す 返却値の範囲[-π, π]
double arg(Vector p){ return atan2(p.y, p.x); }
//大きさa, x軸との角度rのベクトルを返す
Vector polar(double a, double r){ return Point(cos(r)*a, sin(r)*a); }
//円c1と円c2の交点を返す
pair<Point,Point> getCrossPoints(Circle c1, Circle c2){
	assert(getDistance(c1.c,c2.c) < c1.r+c2.r+EPS);
	double d = (c1.c-c2.c).abs();
	double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(c1.r*d*2.));
	double t = arg(c2.c-c1.c);
	return {c1.c+polar(c1.r,t+a), c1.c+polar(c1.r,t-a)};
}

using Polygon = vector<Point>;
//多角形gと点pの内包関係を返す
static const int INSIDE = 2;
static const int ONLINE = 1;
static const int OUTSIDE = 0;
ll contains(Polygon &g, Point p){
	ll n=g.size();
	bool x=false;
	for(ll 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 ONLINE;
		if(a.y > b.y) swap(a,b);
		if(a.y < EPS && EPS < b.y && cross(a,b) > EPS) x=!x;
	}
	return (x ? INSIDE : OUTSIDE);
}

//点の集合sに対する凸包を返す
Polygon andrewScan(Polygon s){
	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]);

	for(ll i=2; i<(ll)s.size(); i++){
		for(ll n=u.size(); n>=2 && ccw(u[n-2],u[n-1],s[i])!=CLOCKWISE; n--){
			u.pop_back();
		}
		u.push_back(s[i]);
	}
	for(ll i=s.size()-3; i>=0; i--){
		for(ll n=l.size(); n>=2 && ccw(l[n-2],l[n-1],s[i])!=CLOCKWISE; n--){
			l.pop_back();
		}
		l.push_back(s[i]);
	}

	reverse(l.begin(), l.end());
	for(ll i=u.size()-2; i>=1; i--)l.push_back(u[i]);

	return l;
}


//線分の集合sの交点の数を返す
class EndPoint {
public:
	Point pnt;
	ll seg,st; //入力線分のID, 端点の種類
	EndPoint() {}
	EndPoint(Point pnt, ll seg, ll st) : pnt(pnt), seg(seg), st(st) {}

	bool operator < (const EndPoint &ep) const {
		if(pnt.y == ep.pnt.y) return st < ep.st;
		return pnt.y < ep.pnt.y;
	}
};
ll manhattanIntersection(vector<Segment> &S){
	static const int BOTTOM = 0;
	static const int LEFT = 1;
	static const int RIGHT = 2;
	static const int TOP = 3;
	ll n=S.size();
	vector<EndPoint> EP(2*n);
	for(ll i=0,k=0; i<n; i++){
		if(S[i].p1.y==S[i].p2.y){
			if(S[i].p1.x>S[i].p2.x) swap(S[i].p1, S[i].p2);
		}else if(S[i].p1.y > S[i].p2.y){
			swap(S[i].p1, S[i].p2);
		}

		if(S[i].p1.y==S[i].p2.y){
			EP[k++]=EndPoint(S[i].p1, i, LEFT);
			EP[k++]=EndPoint(S[i].p2, i, RIGHT);
		}else{
			EP[k++]=EndPoint(S[i].p1, i, BOTTOM);
			EP[k++]=EndPoint(S[i].p2, i, TOP);
		}
	}

	sort(EP.begin(), EP.end());

	set<ll> BT;
	BT.insert(INF);
	ll cnt=0;
	for(ll i=0; i<2*n; i++){
		if(EP[i].st==TOP){
			BT.erase(EP[i].pnt.x);
		}else if(EP[i].st==BOTTOM){
			BT.erase(EP[i].pnt.x);
		}else if(EP[i].st==LEFT){
			auto b=BT.lower_bound(S[EP[i].seg].p1.x);
			auto e=BT.upper_bound(S[EP[i].seg].p2.x);
			cnt+=distance(b,e);
		}
	}
	return cnt;
}


/*-----8<-----library-----8<-----*/

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=ja
void CGL_2_A(){
	ll N;
	cin>>N;
	vector<ll> ans(N,0);
	rep(i,N){
		double x0,y0,x1,y1,x2,y2,x3,y3;
		cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
		Point p0(x0,y0),p1(x1,y1),p2(x2,y2),p3(x3,y3);
		ll t=0;
		if(isOrthogonal(p0,p1,p2,p3)){
			t=1;
		}else if(isParallel(p0,p1,p2,p3)){
			t=2;
		}
		ans[i]=t;
	}
	rep(i,N)p(ans[i]);
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A&lang=ja
void CGL_1_A(){
	double x0,y0,x1,y1;
	cin>>x0>>y0>>x1>>y1;
	Line l(Point(x0,y0),Point(x1,y1));
	ll Q;
	cin>>Q;
	vector<Point> ans(Q,0);
	rep(i,Q){
		double xq,yq;
		cin>>xq>>yq;
		Point po(xq,yq);
		Point t=project(l,po);
		ans[i]=t;
	}
	cout.setf(ios::fixed), cout.precision(20);
	rep(i,Q){
		cout<<ans[i].x<<' '<<ans[i].y<<'\n';
	}
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B&lang=ja
void CGL_1_B(){
	double x0,y0,x1,y1;
	cin>>x0>>y0>>x1>>y1;
	Line l(Point(x0,y0),Point(x1,y1));
	ll Q;
	cin>>Q;
	vector<Point> ans(Q,0);
	rep(i,Q){
		double xq,yq;
		cin>>xq>>yq;
		Point po(xq,yq);
		Point t=reflect(l,po);
		ans[i]=t;
	}
	cout.setf(ios::fixed), cout.precision(20);
	rep(i,Q){
		cout<<ans[i].x<<' '<<ans[i].y<<'\n';
	}
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_D&lang=ja
void CGL_2_D(){
	ll Q;
	cin>>Q;
	vector<double> ans(Q,0);
	rep(i,Q){
		double x0,y0,x1,y1,x2,y2,x3,y3;
		cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
		Segment s0(Point(x0,y0),Point(x1,y1)), s1(Point(x2,y2),Point(x3,y3));
		double t=getDistance(s0,s1);
		ans[i]=t;
	}
	cout.setf(ios::fixed), cout.precision(20);
	rep(i,Q)p(ans[i]);
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C&lang=ja
void CGL_1_C(){
	double x0,y0,x1,y1;
	cin>>x0>>y0>>x1>>y1;
	Point p0(x0,y0),p1(x1,y1);
	ll Q;
	cin>>Q;
	vector<string> ans(Q,"");
	map<ll,string> m;
	m[1]="COUNTER_CLOCKWISE";
	m[-1]="CLOCKWISE";
	m[2]="ONLINE_BACK";
	m[-2]="ONLINE_FRONT";
	m[0]="ON_SEGMENT";
	rep(i,Q){
		double xq,yq;
		cin>>xq>>yq;
		Point pq(xq,yq);
		ll t=ccw(p0,p1,pq);
		ans[i]=m[t];
	}
	rep(i,Q)p(ans[i]);
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B&lang=ja
void CGL_2_B(){
	ll Q;
	cin>>Q;
	vector<ll> ans(Q,0);
	rep(i,Q){
		double x0,y0,x1,y1,x2,y2,x3,y3;
		cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
		Point p0(x0,y0),p1(x1,y1),p2(x2,y2),p3(x3,y3);
		bool t=intersect(p0,p1,p2,p3);
		ans[i]=t ? 1 : 0;
	}
	rep(i,Q)p(ans[i]);	
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_C&lang=ja
void CGL_2_C(){
	ll Q;
	cin>>Q;
	vector<Point> ans(Q,0);
	rep(i,Q){
		double x0,y0,x1,y1,x2,y2,x3,y3;
		cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
		Point p0(x0,y0),p1(x1,y1),p2(x2,y2),p3(x3,y3);
		Segment s0(p0,p1),s1(p2,p3);
		Point t=getCrossPoint(s0,s1);
		ans[i]=t;
	}
	cout.setf(ios::fixed), cout.precision(20);
	rep(i,Q)p(ans[i].x,ans[i].y);
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_D&lang=ja
void CGL_7_D(){
	ll cx,cy,r,Q;
	cin>>cx>>cy>>r>>Q;
	Circle c(Point(cx,cy),r);
	vector<pair<Point,Point>> ans(Q);
	rep(i,Q){
		double x0,y0,x1,y1;
		cin>>x0>>y0>>x1>>y1;
		Point p0(x0,y0),p1(x1,y1);
		Line l(p0,p1);
		ll count=hasCrossPoints(c,l);
		if(count==0)exit(1);
		pair<Point,Point> t=getCrossPoints(c,l);
		if(t.first.x>t.second.x || (equals(t.first.x,t.second.x) && t.first.y>t.second.y))swap(t.first,t.second);
		ans[i]=t;
	}
	cout.setf(ios::fixed), cout.precision(20);
	rep(i,Q)p(ans[i].first.x, ans[i].first.y, ans[i].second.x, ans[i].second.y);
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_E&lang=ja
void CGL_7_E(){
	double c0x,c0y,r0,c1x,c1y,r1;
	cin>>c0x>>c0y>>r0>>c1x>>c1y>>r1;
	Circle c0(Point(c0x,c0y), r0), c1(Point(c1x,c1y), r1);
	pair<Point,Point> t=getCrossPoints(c0, c1);
	if(t.first.x>t.second.x || (equals(t.first.x,t.second.x) && t.first.y>t.second.y))swap(t.first,t.second);
	cout.setf(ios::fixed), cout.precision(20);
	p(t.first.x, t.first.y, t.second.x, t.second.y);
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_C&lang=ja
void CGL_3_C(){
	ll N;
	cin>>N;
	vector<Point> g(N);
	rep(i,N)cin>>g[i].x>>g[i].y;
	ll Q;
	cin>>Q;
	vector<ll> ans(Q,0);
	rep(i,Q){
		ll x,y;
		cin>>x>>y;
		ll t=contains(g,Point(x,y));
		ans[i]=t;
	}
	rep(i,Q)p(ans[i]);
}

signed main() {
	//CGL_2_A();
	//CGL_1_A();
	//CGL_1_B();
	//CGL_2_D();
	//CGL_1_C();
	//CGL_2_B();
	//CGL_2_C();
	//CGL_7_D();
	//CGL_7_E();
	CGL_3_C();

	return 0;
}



Measured memory_bytes: 3244