require 'matrix'

class Polygon
  attr_accessor :points
  def initialize
    @points = []
  end
end

def cross(p1, p2)
  return p1[0]*p2[1] - p1[1]*p2[0]
end

poly = Polygon.new
gets.to_i.times do
  x, y = gets.split.map &:to_i
  point = Vector[x, y]
  poly.points << point
end

gets.to_i.times do
  x, y = gets.split.map &:to_i
  q = Vector[x, y]
  n = 0
  on_segment = false
  poly.points.each_with_index do |v, i|
    a = poly.points[i] - q
    b = poly.points[(i+1) % poly.points.size] - q
    if cross(a, b) == 0 && a.inner_product(b) <= 0
      on_segment = true
      break
    end
    a, b = b, a if a[1] > b[1]
    n += 1 if a[1] <= 0 && b[1] > 0 && cross(a,b) > 0
  end
  if on_segment
    puts 1
  else
    puts n.odd?? 2 : 0
  end
end