n = gets.to_i
p = []
n.times{|i|
  p[i] = gets.split.map(&:to_i)
}
p << p[0]
q = gets.to_i
q.times{
  x, y = gets.split.map(&:to_i)
  count = 0
  on_line = false
  n.times{|i|
    a = [p[i  ][0] - x, p[i  ][1] - y]
    b = [p[i+1][0] - x, p[i+1][1] - y]
    if  a[0]*b[1] - a[1]*b[0] == 0 && a[0]*b[0]+a[1]*b[1] <= 0
      on_line = true
      break
    end
    a, b = b, a if a[1] > b[1]
    count += 1 if a[1] <= 0 && b[1] > 0 && a[0]*b[1] - a[1]*b[0] > 0
  }
  if on_line == true
    puts "1"
  elsif count % 2 == 0
    puts "0"
  else
    puts "2"
  end
}