#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i,n) for(UL i=0; i<(n); i++)

UL N;
pair<int,int> P[524288];

struct RT{
 UL N;
 UL D;
 tuple<int,int,UL> V[20][524288];
 void init(UL n){
  N=1; D=0; while(N<n){ D++; N<<=1; }
  rep(i,n) V[0][i] = make_tuple(P[i].first,P[i].second,i);
  for(UL i=n; i<N; i++) V[0][i] = make_tuple(INT_MAX,INT_MAX,0);
  sort(V[0],V[0]+N);
  for(UL d=0; d<D; d++){
   UL L=(1<<d);
   for(UL l=0; l<N; l+=(L+L)){
    UL p=0, q=0;
    while(p+q<L+L){
     bool choose_p = false;
     if(q==L) choose_p=true;
     else if(p<L) if(get<1>(V[d][l+p]) <= get<1>(V[d][l+L+q])) choose_p=true;
     if(choose_p) { V[d+1][l+p+q]=V[d][l+p]; p++; }
     else { V[d+1][l+p+q]=V[d][l+L+q]; q++; }
    }
   }
  }
 }
 const vector<UL>& query(int xl,int xr,int yl,int yr,UL a=~0u,UL b=~0u,UL d=~0u){
  static vector<UL> ans;
  if(!~d){ a=0; b=N; d=D; ans.clear(); }
  if(xr<=get<0>(V[0][a]) || get<0>(V[0][b-1])<xl) return ans;
  if(xl<=get<0>(V[0][a]) && get<0>(V[0][b-1])<xr) {
   UL pl,pr;
   UL l,r;
   l=a; r=b+1;
   while(l+1<r){ UL m=(l+r)>>1;
    if(get<1>(V[d][m-1])<yl) l=m; else r=m;
   } pl=l;
   l=a; r=b+1;
   while(l+1<r){ UL m=(l+r)>>1;
    if(get<1>(V[d][m-1])<yr) l=m; else r=m;
   } pr=l;
   for(UL p=pl; p<pr; p++) ans.push_back(get<2>(V[d][p]));
   return ans;
  }
  query(xl,xr,yl,yr,a,(a+b)>>1,d-1);
  query(xl,xr,yl,yr,(a+b)>>1,b,d-1);
  return ans;
 }
} G;

int main() {
 scanf("%u",&N);
 rep(i,N) scanf("%d%d",&P[i].first,&P[i].second);
 G.init(N);
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  int xl,xr,yl,yr; scanf("%d%d%d%d",&xl,&xr,&yl,&yr);
  auto ans=G.query(xl,xr+1,yl,yr+1);
  sort(ans.begin(),ans.end());
  for(UL a:ans) printf("%u\n",a);
  printf("\n");
 }
 return 0;
}

