class KDTree
  Node = Struct.new(:location, :left, :right)

  attr_reader :points, :nodes

  def initialize(points)
    @points = points.dup
    @nodes = []
    @pos = 0
  end

  def build(l, r, depth=0)
    return nil unless l < r

    mid = (l + r) / 2

    pos = @pos
    @pos += 1

    if depth % 2 == 0
      @points[l...r] = @points[l...r].sort! {|a, b| a.x <=> b.x }
    else
      @points[l...r] = @points[l...r].sort! {|a, b| a.y <=> b.y }
    end

    node = Node.new

    node.location = mid
    node.left = build(l, mid, depth + 1)
    node.right = build(mid + 1, r, depth + 1)

    @nodes[pos] = node

    pos
  end

  def find(id, x1, x2, y1, y2, depth=0)
    ret = []

    node = @nodes[id]
    point = @points[node.location]

    x = point.x
    y = point.y

    if x1 <= x && x <= x2 && y1 <= y && y <= y2
      ret << point
    end

    if depth % 2 == 0
      if node.left && x1 <= x
        ret.concat(find(node.left, x1, x2, y1, y2, depth + 1))
      end

      if node.right && x <= x2
        ret.concat(find(node.right, x1, x2, y1, y2, depth + 1))
      end
    else
      if node.left && y1 <= y
        ret.concat(find(node.left, x1, x2, y1, y2, depth + 1))
      end

      if node.right && y <= y2
        ret.concat(find(node.right, x1, x2, y1, y2, depth + 1))
      end
    end

    ret
  end
end

Point = Struct.new(:id, :x, :y)

if $PROGRAM_NAME == __FILE__
  points = []

  n = gets.to_i
  n.times do |id|
    x, y = gets.chomp.split.map(&:to_i)
    points << Point.new(id, x, y)
  end

  tree = KDTree.new(points)
  root = tree.build(0, points.size)

  q = gets.to_i
  q.times do
    x1, x2, y1, y2 = gets.chomp.split.map(&:to_i)
    ret = tree.find(root, x1, x2, y1, y2)

    if ret.empty?
      puts
    else
      puts ret.sort_by(&:id).map(&:id).join("\n")
      puts
    end
  end
end