output_description: For each query, report IDs of points such that sxi ≤ x ≤ txi and syi ≤ y ≤
  tyi. The IDs should be reported in ascending order. Print an ID in a line, and
  print a blank line at the end of output for the each query.
input_description: n
      x0 y0
      x1 y1
      :
      xn-1 yn-1
      q
      sx0 tx0 sy0 ty0
      sx1 tx1 sy1 ty1
      :
      sxq-1 txq-1 syq-1 tyq-1
      
  
  The first integer n is the number of points. In the following n lines, the
  coordinate of the i-th point is given by two integers xi and yi.
  
  The next integer q is the number of queries. In the following q lines, each
  query is given by four integers, sxi, txi, syi, tyi.
attempt: n = int(input())
  
  
  def memoize(f):
      global n
      memo = [-1] * n
  
      def main(x):
          result = memo[x]
          if result == -1:
              result = memo[x] = f(x)
          return result
  
      return main
  
  
  class Bound:
      def __init__(self, sx, tx, sy, ty):
          self.sx = sx
          self.tx = tx
          self.sy = sy
          self.ty = ty
  
      def contains(self, point):
          return self.sx <= point[1] <= self.tx and self.sy <= point[2] <= self.ty
  
      def update_intersection(self, intersection, point, horizontal):
          sx, tx, sy, ty = intersection
          div = point[2 if horizontal else 1]
          if horizontal:
              return (sx, tx, sy, self.ty >= div) if self.sy <= div else None, (
                  (sx, tx, self.sy <= div, ty) if self.ty >= div else None
              )
          else:
              return (sx, self.tx >= div, sy, ty) if self.sx <= div else None, (
                  (self.sx <= div, tx, sy, ty) if self.tx >= div else None
              )
  
  
  class Kdt:
      LIMIT_TREE_NODES = 2**8 - 1
  
      def __init__(self, n, points):
          self.n = n
          self.tree = [None] * n
  
          self._build(0, points, n)
  
      def _build(self, i, points, num):
          depth = self.depth(i)
  
          if num <= self.LIMIT_TREE_NODES:
              self.tree[i] = (None, set(points) if depth >= 4 else None)
              return
  
          rnum = (num - 1) // 2
          lnum = num - rnum - 1
          xy_index = 2 if depth & 1 else 1
  
          sorted_points = sorted(points, key=lambda p: p[xy_index])
          self.tree[i] = (sorted_points[lnum], set(p[0] for p in points))
          if lnum:
              self._build(i * 2 + 1, sorted_points[:lnum], lnum)
              if rnum:
                  self._build(i * 2 + 2, sorted_points[lnum + 1 :], rnum)
  
      def search(self, i, bound, intersection):
          node = self.tree[i]
          point = node[0]
  
          if point is None:
              return set(p[0] for p in node[1] if bound.contains(p))
  
          if all(intersection):
              return node[1]
  
          result = {point[0]} if bound.contains(point) else set()
          li, ri = i * 2 + 1, i * 2 + 2
  
          if li < self.n:
              lis, ris = bound.update_intersection(intersection, point, self.depth(i) & 1)
              if lis:
                  result |= self.search(li, bound, lis)
              if ris and ri < self.n:
                  result |= self.search(ri, bound, ris)
          return result
  
      @staticmethod
      @memoize
      def depth(x):
          """x>=0"""
          i, x = 0, (x + 1) // 2
          while x:
              x //= 2
              i += 1
          return i
  
  
  point_list = [(i,) + tuple(map(int, input().split())) for i in range(n)]
  kdt = Kdt(n, point_list)
  
  q = int(input())
  while q:
      inside_points = kdt.search(0, Bound(*map(int, input().split())), tuple([False] * 4))
      if inside_points:
          print("\n".join(map(str, sorted(inside_points))))
      print()
      q -= 1
  
problem_description: Range Search (kD Tree)
  
  The range search problem consists of a set of attributed records S to
  determine which records from S intersect with a given range.
  
  For n points on a plane, report a set of points which are within in a given
  range. Note that you do not need to consider insert and delete operations for
  the set.
samples: [{"input": "6\n    2 1\n    2 2\n    4 2\n    6 2\n    3 3\n    5 4\n    2\n    2 4 0 4\n    4 10 2 5", "output": "0\n    1\n    2\n    4\n    \n    2\n    3\n    5"}]