class Tree
  attr_accessor :t, :p

  class Node
    attr_accessor :l, :r, :location
  end

  class Point
    attr_accessor :id, :x, :y

    def initialize(id, x, y)
      @id, @x, @y = id, x, y
    end
  end

  def initialize(n)
    @t = Array.new(n) { Node.new }
    @np = 0
    @p = []
    n.times do |i|
      x, y = gets.split.map &:to_i
      @p[i] = Point.new(i, x, y)
    end
    make_2d_tree(0, n, 0)
  end

  def make_2d_tree(l, r, depth)
    return nil unless l < r
    mid = ( l + r ) / 2
    t = @np
    @np += 1
    if depth.even?
      @p[l..(r-1)] = @p[l..(r-1)].sort { |p1, p2| p1.x <=> p2.x }
    else
      @p[l..(r-1)] = @p[l..(r-1)].sort { |p1, p2| p1.y <=> p2.y }
    end
    @t[t].location = mid
    @t[t].l = make_2d_tree(l, mid, depth + 1)
    @t[t].r = make_2d_tree(mid + 1, r, depth + 1)
    return t
  end

  def find(v, sx, tx, sy, ty, depth, ans)
    x = @p[@t[v].location].x
    y = @p[@t[v].location].y

    if (sx..tx).include?(x) && (sy..ty).include?(y)
      ans << @p[@t[v].location]
    end

    if depth.even?
      find(@t[v].l, sx, tx, sy, ty, depth + 1, ans) if @t[v].l && sx <= x
      find(@t[v].r, sx, tx, sy, ty, depth + 1, ans) if @t[v].r && x <= tx
    else
      find(@t[v].l, sx, tx, sy, ty, depth + 1, ans) if @t[v].l && sy <= y
      find(@t[v].r, sx, tx, sy, ty, depth + 1, ans) if @t[v].r && y <= ty
    end
  end

end

n = gets.to_i
tree = Tree.new(n)
q = gets.to_i
q.times do
  ans = []
  sx, tx, sy, ty = gets.split.map &:to_i
  tree.find(0, sx, tx, sy, ty, 0, ans)
  if !ans.empty?
    puts ans.map { |i| i.id }.sort * "\n"
    puts
  end
end