#include <bits/stdc++.h>
using namespace std;
typedef complex <double> point;
vector <point> pol;

bool eq(double a,double b){
  return (abs(a-b)<=(1e-9));
}

bool on_segment(point a,point b,point c){
  return eq(abs(b-a),abs(a-c)+abs(b-c));
}

double get_r(point a,point b,point c){
  b-=a,c-=a;
  b*=conj(c);
  return arg(b);
}

int solve(point a){
  for(int i=0;i<pol.size();i++)
    if(on_segment(pol[i],pol[(i+1)%pol.size()],a)) return 1;
 
  double sum=0;
  for(int i=0;i<pol.size();i++)
    sum+=get_r(a,pol[i],pol[(i+1)%pol.size()]);

  if(abs(sum)<=0.0001)return 0;
  return 2;
}


int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) {
    double a,b;
    cin>>a>>b;
    pol.push_back(point(a,b));
  }

  int q;
  cin>>q;
  while(q--){
    double a,b;
    cin>>a>>b;
    cout<<solve(point(a,b))<<endl;
  }
  return 0;
}