class Node
  attr_accessor :location, :left, :right
  def initialize(location)
    @location = location
    @left = nil
    @right = nil
  end
end

def kdtree(arr, depth)
  return nil if arr.size == 0
  k = arr[0].size - 1
  axis = depth % k

  arr.sort_by!{|x| x[axis]}
#  p arr
  median = arr.size / 2

  node = Node.new(arr[median])
  node.left = kdtree(arr[0,median], depth+1)
  node.right = kdtree(arr[median+1..-1], depth+1)
  return node
end

def range_search(tree, sx, tx, sy, ty)
  return [] unless tree
  ans = []
  x = tree.location[0]
  y = tree.location[1]
  i = tree.location[2]
  ans << i if sx <= x && x <= tx && sy <= y && y <= ty
  ans += range_search(tree.left, sx, tx, sy, ty)
  ans += range_search(tree.right, sx, tx, sy, ty)
  return ans
end

arr = []

n = gets.to_i

n.times{|i|
  x, y = gets.split.map(&:to_i)
  arr[i] = [x, y, i]
}
tree = kdtree(arr, 0)

q = gets.to_i

q.times{
  sx, tx, sy, ty = gets.split.map(&:to_i)
  ans = range_search(tree, sx, tx, sy, ty)
  ans.sort.each{|i|
    puts i
  }
  puts
}