import std.algorithm,
       std.string,
       std.conv;
import core.stdc.stdio;

struct Point {
  int id, x, y;
  int opCmp(ref const Point p) const {
    if (id < p.id) {
      return -1;
    } else if (id == p.id) {
      return 0;
    } else {
      return 1;
    }
  }
}

class KDtree {
  class Node {
    size_t p;
    Node left;
    Node right;
  }

  size_t N;
  Node root;
  Point[] P;

  Node make_kd_tree(size_t l, size_t r, int depth) {
    if (!(l < r)) return null;
    size_t mid = (l + r) / 2;

    if (depth) P[l..r].sort!"a.y<b.y";
    else       P[l..r].sort!"a.x<b.x";

    Node t = new Node();
    t.p = mid;
    t.left = make_kd_tree(l, mid, !depth);
    t.right = make_kd_tree(mid+1, r, !depth);
    return t;
  }
  void find(Node v, int sx, int sy, int tx, int ty, int depth, ref Point[] ans) {
    if (v is null) return;

    int x = P[v.p].x;
    int y = P[v.p].y;

    if (sx <= x && x <= tx && sy <= y && y <= ty) {
      ans ~= P[v.p];
    }

    if (depth ? sy <= y : sx <= x) find(v.left, sx, sy, tx, ty, !depth, ans);
    if (depth ? y <= ty : x <= tx) find(v.right, sx, sy, tx, ty, !depth, ans);
  }

  this (Point[] p) {
    this.P = p;
    this.N = p.length;
    this.root = make_kd_tree(0, N, 0);
  }

  void query(int sx,int sy,int tx,int ty, ref Point[] p) {
    find(root, sx, sy, tx, ty, 0, p);
  }
}
 
void main() {
  int n;
  scanf("%d", &n);
  Point[] p;
  p.length = n;

  for (int i = 0; i < n; i++) {
    p[i].id = i;
    scanf("%d %d", &p[i].x, &p[i].y);
  }
  KDtree tree = new KDtree(p);
  int q;
  scanf("%d", &q);
  while (q--) {
    int sx, tx, sy, ty;
    scanf("%d %d %d %d", &sx, &tx, &sy, &ty);

    Point[] ans;
    tree.query(sx, sy, tx, ty, ans);

    ans.sort!"a<b";
    for (size_t i; i < ans.length; i++) {
      printf("%d\n", ans[i].id);
    }
    printf("\n");
  }
}