using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

public class Program
{
  public struct Node
  {
    public int location;
    public int point, left, right;
    public Node(int left, int right, int point, int location) {
      this.point = point;
      this.left = left;
      this.right = right;
      this.location = location;
    }
  }

  public struct Point : System.IComparable
  {
    public int id, x, y;
    public Point(int id, int x, int y) {
      this.id = id;
      this.x = x;
      this.y = y;
    }

    public int CompareTo(object obj)
    {
      if(obj == null) { return 1; }
      if (this.GetType() != obj.GetType()) { return -1; }
      Point p = (Point) obj;
      return this.id.CompareTo(p.id);
    }

    public void print()
    {
      Console.Write("{0}\n", id);
    }
  }

  public class MyComparatorX : IComparer<Point>
  {
    public int Compare(Point p1, Point p2)
    {
//      Point p1 = (Point) o1;
//      Point p2 = (Point) o2;
//      return p1.x.CompareTo(p2.x);
	    return p1.x - p2.x;
    }
  }

  public class MyComparatorY : IComparer<Point>
  {
    public int Compare(Point p1, Point p2)
    {
//      Point p2 = (Point) o2;
//      Point p1 = (Point) o1;
//      return p1.y.CompareTo(p2.y);
		return p1.y - p2.y;
    }
  }

  static readonly int MAX = 500000;
  static readonly int NIL = -1;

  static int N;
  static Point[] P = new Point[MAX];
  static Node[] T = new Node[MAX];
  static int np;
  static List<Point> answer = new List<Point>();

//  static int lessX(Point p1, Point p2) { return p1.x - p2.x; }
//  static int lessY(Point p1, Point p2) { return p1.y - p2.y; }

  static int makeKDTree(int left, int right, int depth)
  {
    if(!(left < right)) { return NIL; }
    int mid = (left + right) / 2;
    int t = np++;
    if(depth%2 == 0)
    {
	  Array.Sort(P, left, right-left, new MyComparatorX());
    } else {
	  Array.Sort(P, left, right-left, new MyComparatorY() );
    }

    T[t].location = mid;
    T[t].left = makeKDTree(left, mid, depth+1);
    T[t].right = makeKDTree(mid+1, right, depth+1);

    return t;
  }

  static void find(int v, int sx, int tx, int sy, int ty, int depth)
  {
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if(sx <= x && x <=tx && sy <= y && y <= ty)
    {
      answer.Add(P[T[v].location]);
    }
	
    if(depth%2 == 0)
    {
      if(T[v].left != NIL)
      {
	if(sx<=x) { find(T[v].left, sx, tx, sy, ty, depth+1); }
      }
      if(T[v].right != NIL)
      {
	if(x<=tx) { find(T[v].right, sx, tx, sy, ty, depth+1); }
      }
    } else {
      if(T[v].left != NIL)
      {
	if(sy<=y) { find(T[v].left, sx, tx, sy, ty, depth+1); }
      }
      if(T[v].right != NIL)
      {
	if(y<=ty) { find(T[v].right, sx, tx, sy, ty, depth+1); }
      }
    }
  }

  public static void Main()
  {
    var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
	Console.SetOut(sw);

    N = int.Parse(Console.ReadLine());

    for(int i=0; i<N; i++)
    {
      string[] p = Console.ReadLine().Split(' ');
//      Console.Write("{0} {1}", p[0], p[1]);
	  P[i] = new Point(i, int.Parse(p[0]), int.Parse(p[1]));
	  Node node;
	  node.left = node.right = node.point = node.location = NIL;
	  T [i] = node;
//      T[i].left = T[i].right = T[i].point = NIL;
//      Console.Write("T[i].left={0}, T[i].right{1}=, T[i].point={2}, Point.x={3}, Point.y={4}, Point.id={5}\n", T[i].left, T[i].right, T[i].point, P[i].x, P[i].y, P[i].id);
    }

    int np = int.Parse(Console.ReadLine());
    int root = makeKDTree(0, N, 0);

    for(int i=0; i<np; i++)
    {
      string[] p = Console.ReadLine().Split(' ');
      answer.Clear();
      find(root, int.Parse(p[0]), int.Parse(p[1]), int.Parse(p[2]), int.Parse(p[3]), 0);

      answer.Sort();
      for(int j=0; j<answer.Count; j++)
      {
		answer[j].print();
      }
      Console.Write("\n");
    }
	Console.Out.Flush();
  }
}

Measured memory_bytes: 34852