#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

const double eps = 1e-10;
const double sv = 0.01;

class Vector
{
public:
  double x;
  double y;

  Vector(){}
  Vector( double x, double y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const double k ) { return Vector( x * k, y * k ); }
  Vector operator / ( const double k ) { return Vector( x / k, y / k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double abs() { return sqrt( norm() ); }
  double norm() { return x * x + y * y; }

  static double dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static double cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }
  
  static int ccw( Vector v1, Vector v2, Vector v3);
  static int crossCheck( Vector v1, Vector v2, Vector v3, Vector v4 );
  static bool boundaryCheck( Vector v1, Vector v2, Vector v3);
  void print() { cout << fixed << setprecision(10) << x << " " << y << endl; }
};

int Vector::ccw( Vector v1, Vector v2, Vector v3 )
{
  Vector v21 = v2 - v1;
  Vector v31 = v3 - v1;
  Vector v12 = v1 - v2;
  Vector v32 = v3 - v2;

  double crv = Vector::cross( v21, v31 );
  double dtv = Vector::dot( v21, v31 );
  double rdtv = Vector::dot( v12, v32 );
  
  if ( fabs( crv ) < eps )
    {
      if ( dtv < -eps )
        return 2;
      else if ( rdtv < -eps )
        return 3;
      else
        return 0;
    }
  else if ( crv > 0 )
    return 1;
  else 
    return -1;
}

bool Vector::boundaryCheck( Vector v1, Vector v2, Vector v3 )
{
  if ( ccw( v1, v2, v3 ) == 0 )
    return true;
  else
    return false;
}

int Vector::crossCheck( Vector v1, Vector v2, Vector v3, Vector v4 )
{

  double c123 = ccw( v1, v2, v3 );
  double c124 = ccw( v1, v2, v4 );
  double c341 = ccw( v3, v4, v1 );
  double c342 = ccw( v3, v4, v2 );

  if ( c123 * c124 == 1 || c341 * c342 == 1 )
    return 0;
  else if ( c123 * c124 == -1 && c341 * c342 == -1 )
    return 1;
  else if ( c123 * c124 == 0 )
    return 2;
  else
    return 0;
}

class Polygon
{
public:
  int n;
  vector<Vector> pt;
  Polygon(){}
  Polygon( int n ) : n(n), pt(n) {}
  int solve( Vector p );
};

int Polygon::solve( Vector p )
{
  int cnt = 0;

  for ( auto i = 0; i < n; ++i )
    {
      if ( Vector::boundaryCheck( pt[i], pt[(i+1) % n], p ) )
        {
          cout << "1" << endl;
          return 0;
        }
    }
  
  for ( auto i = 0; i < n; ++i )
    {
      Vector v1 = pt[i] - p;
      Vector v2 = pt[(i+1) % n] - p;

      if ( v1.y < v2.y )
        {
          if ( Vector::cross( v1, v2 ) > eps  && v2.y > eps && v1.y < eps )
            ++cnt;
        }
      else
        {
          if ( Vector::cross( v2, v1 ) > eps && v1.y > eps && v2.y < eps )
            ++cnt;
        }
    }

  if ( cnt % 2 == 0 )
    cout << "0" << endl;
  else
    cout << "2" << endl;
  
  return 0;
}

int main()
{
  int n;
  cin >> n;

  Polygon g( n );
  
  for ( auto i = 0; i < n; ++i )
    {
      double x, y;
      cin >> x >> y;
      g.pt[i] = Vector( x, y );
    }
  
  int q;
  cin >> q;
  
  for ( auto i = 0; i < q; ++i )
    {
      double x, y;
      cin >> x >> y;
      g.solve( Vector(x, y) );
    }

  return 0;
}

Measured memory_bytes: 1228