#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;


// 以下 幾何部分
template<class T> bool operator==(T a, T b){return abs(a-b)< eps;}
template<class T> bool operator< (T a, T b){return a < b-eps;}
template<class T> bool operator<=(T a, T b){return a < b+eps;}
template<class T> int sig(T r) {return (r==0||r==-0) ? 0 : r > 0 ? 1 : -1;}
#define X real()
#define Y imag()
#define mp make_pair

typedef bool B;
typedef long double D;
typedef complex<D> P;
typedef vector<P> VP;
typedef pair <P,P> L;
typedef vector<L> VL;
typedef struct {P c;D r;} C;
typedef struct {P c;D a,b;} E; // 楕円も追加予定
typedef vector <P> Pol;

// ソートのキー
B cmp_x(const P &a,const P &b){ return (abs(a.X-b.X)<eps ) ?  a.Y<b.Y : a.X<b.X;}  // base x
B cmp_y(const P &a,const P &b){ return (abs(a.Y-b.Y)<eps ) ?  a.X<b.X : a.Y<b.Y;}  // base y
B cmp_a(const P &a,const P &b){ return (abs(arg(a)-arg(b))<eps ) ?  norm(a) < norm(b) : arg(a)<arg(b);} // base arg


// 基本操作
// verify
D ip(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D ep(P a, P b) {return a.X * b.Y - a.Y * b.X;}
D sr(D a) {return sqrt(max(a, (D)0));}
P vec(L l){return l.second-l.first;}


// 点
D toRagian(D degree){ return degree*pi/180.0;}
D ang (P p){return arg(p);}
D ang (P base, P a, P b) {return arg( (b - base) / (a - base) );} // base 中心
P rot (P base, P a, D theta){return base+polar( abs(a-base), arg(a-base)+theta );}


// ccw 
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, MID = 16, ON=FRONT|BACK|MID };

int ccw(P base, P a, P b) {              //点aと点bが与えられた問いに
  a -= base; b -= base;
  if (ep(a, b) > 0)   	 return LEFT;    // counter clockwise
  if (ep(a, b) < 0)      return RIGHT;   // clockwise
  if (ip(a, b) < 0)      return BACK;    // b--base--a on line
  if (norm(a) < norm(b)) return FRONT;   // base--a--b on line
  						 return MID;      // base--b--a on line  aとbの線分判定はこれ
}




// 多角形

int in_polygon(Pol pol,P p){
	int n=pol.size();
    int res=0;
	rep(i,n){
		if(ccw(pol[i],pol[(i+1)%n],p)==MID)
			return 1;
		if ((pol[i].Y <= p.Y) && (pol[(i+1)%n].Y>p.Y)){
			D vt=(p.Y-pol[i].Y)/(pol[(i+1)%n].Y-pol[i].Y);
			D dx=pol[(i+1)%n].X-pol[i].X;
			if(p.X < pol[i].X + vt*dx)
                    res++;
		}else if ((pol[i].Y>p.Y)&&(pol[(i+1)%n].Y<=p.Y)){
			D vt=(p.Y - pol[i].Y)/(pol[(i+1)%n].Y-pol[i].Y);
			D dx=pol[(i+1)%n].X-pol[i].X;
			if(p.X <pol[i].X+vt*dx)
				res--;
		}
    }
	return res?2:0;
}


int main(void){
	int n;
	cin >> n;
	Pol pol(n);
	rep(i,n){
		P in;
		cin >> in.X >> in.Y;
		pol[i]=in;
	}
	int q;
	cin >> q;
	rep(i,q){
		P p;
		cin >> p.X >> p.Y;
		cout << in_polygon(pol,p) << endl;
	}
	return 0;
}

Measured memory_bytes: 1256