#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

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(){
    printf("%d\n",id);
  }

};

static const int MAX=1000000;
static const int NIL=-1;

int n;
point p[MAX];
node T[MAX];
int np;

bool lessx(const point &p1, const point &p2){return p1.x < p2.x;}
bool lessy(const point &p1, const point &p2){return p1.y < p2.y;}

int make2Dtree(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+l,p+r,lessx);
  }else{
    sort(p+l,p+r,lessy);
  }
  T[t].location=mid;
  T[t].l=make2Dtree(l,mid,depth+1);
  T[t].r=make2Dtree(mid+1,r,depth+1);

  return t;
}

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(){
  int x,y;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    p[i]=point(i,x,y);
    T[i].l=T[i].r=T[i].P=NIL;
  }

  np=0;

  int root=make2Dtree(0,n,0);

  int q;
  scanf("%d",&q);
  int sx,tx,sy,ty;
  vector<point> ans;
  for(int i=0;i<q;i++){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    for(int j=0;j<ans.size();j++){
      ans[j].print();
    }
    printf("\n");
  }

  return 0;
}





