#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

class KDTree {
public:
  class Node {
  public:
    int location;
    int p, l, r;
    Node() {}
  };
  class Point {
  public:
    int id,x,y;
    Point() {}
    Point(int id,int x,int y): id(id), x(x), y(y) {}
    bool operator < (const Point &p) const {
      return id < p.id;
    }
    void print() {
      cout << id << '\n';
    }
  };
  
  static const int NIL = -1;

  int N;
  vector<Point> P;
  vector<Node> T;
  int np, root;

  KDTree() {}
  KDTree(int N) {init(N);}

  void init(int N_) {
    N = N_;
    P.clear();
    T.clear();
    P.resize(N);
    T.resize(N);
    rep(i, N) T[i].l = T[i].r = T[i].p = NIL;
    np = 0;
  }

  void insert(int i, int x, int y) {
    P[i] = Point(i, x, y);
  }
  
  static bool lessX(const Point &p1,const Point &p2) {return p1.x < p2.x;}
  static bool lessY(const Point &p1,const Point &p2) {return p1.y < p2.y;}

  void build() {
    root = makeKDTree(0, N, 0);
  }
  int makeKDTree(int l,int r,int depth) {
    if (!(l<r)) return NIL;
    int mid = (l + r) / 2;
    int t = np++;
    if (depth % 2 == 0) {
      sort(P.begin() + l, P.begin() + r, lessX);
    }
    else {
      sort(P.begin() + l, P.begin() + r, lessY);
    }
    T[t].location = mid;
    T[t].l = makeKDTree(l,mid,depth+1);
    T[t].r = makeKDTree(mid+1,r,depth+1);
    return t;
  }

  void find(int sx, int tx, int sy, int ty, vector<Point> &ans) {
    find(root, sx, tx, sy, ty, 0, ans);
  }
  void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;
    if (sx <= x && x <= tx && sy <= y && y <= ty) {
      ans.push_back(P[T[v].location]);
    }
    if(depth % 2 == 0) {
      if(T[v].l != NIL) {
	      if(sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
      }
      if(T[v].r != NIL) {
	      if(x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
      }
    }
    else{
      if(T[v].l != NIL) {
	      if(sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
      }
      if(T[v].r != NIL) {
	      if(y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
      }
    }
  } 
};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  KDTree kdtree(n);
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    kdtree.insert(i, x, y);
  }

  kdtree.build();
  vector<KDTree::Point> ans;
  int q;
  cin >> q;
  while (q--) {
    int sx, tx, sy, ty;
    cin >> sx >> tx >> sy >> ty;
    ans.clear();
    kdtree.find(sx, tx, sy, ty, ans);
    sort(ans.begin(), ans.end());
    rep(i, ans.size()) ans[i].print();
    cout << '\n';
  }

  
  return 0;
}


Measured memory_bytes: 16228