#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
  
using namespace std;

typedef long long ll;

class Point {
public:
  ll x, y;
  
  Point () {}
  Point ( ll x = 0, ll y = 0 ) : x(x), y(y) {}
  
  Point operator - ( const Point &p ) const { return Point(x - p.x, y - p.y); }
};
  
typedef Point Vector;
  
typedef vector<Point> Polygon;
  
ll dot( Vector a, Vector b ) { return a.x*b.x + a.y*b.y; }
ll cross( Vector a, Vector b ) { return a.x*b.y - a.y*b.x; }

/*
  contain: 2
  on segment: 1
  the other case: 0
*/
int
pointInPolygon(Polygon G, Point p) {
  
  int n = G.size();
  bool x = false;
  
  for(int i=0; i<n; i++) {
    Vector V1 = G[i] - p, V2 = G[(i+1)%n] - p;
    
    if( V1.y > V2.y ) swap(V1, V2);
    if( V1.y <= 0 && 0 < V2.y && cross(V1, V2) > 0 ) x = !x;
    if( cross(V1, V2) == 0 && dot(V1, V2) <= 0 ) return 1;
  }
  return (x?2:0);
}
  
int
main() {
  int n, q;
  ll x, y;
    
  Polygon G;
  cin >> n;
    
  for(int i=0; i<n; i++) {
    cin >> x >> y;
    G.push_back(Point(x, y));
  }
    
  cin >> q;
  for(int i=0; i<q; i++) {
    cin >> x >> y;
    cout << pointInPolygon(G, Point(x, y)) << endl;
  }
  return 0;
}