#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define endl "\n"


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

class kD_tree{
  public:
    struct Node{
      ll pos;
      ll par, lef, rig;
      Node() {}
    };
    struct Point{
      ll id;
      ll x, y;
      bool operator < (const Point &p){
        return id < p.id;
      }
    };

  private:
    ll N;
    ll np = 0;
    const ll NIL = -1;
  
  public:
    vector<Node> T;
    vector<Point> P;

    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;}

    kD_tree(ll n){
      N = n;
      T.resize(N); P.resize(N);
    }

    ll make_tree(ll l, ll r,ll depth){
      if(l >= r) return NIL;

      ll mid = (l + r) / 2;
      ll 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].pos = mid;
      T[t].lef = make_tree(l,mid,depth+1);
      T[t].rig = make_tree(mid+1,r,depth+1);

      return t;
    }

    void find(ll v, ll sx, ll tx, ll sy, ll ty, ll depth, vector<Point> &ans){
      ll x = P[T[v].pos].x;
      ll y = P[T[v].pos].y;
      if(sx <= x && x <= tx && sy <= y && y <= ty){
        ans.push_back(P[T[v].pos]);
      }

      if(depth % 2 == 0){
        if(T[v].lef != NIL && sx <= x){
          find(T[v].lef, sx, tx, sy, ty, depth+1, ans);
        }
        if(T[v].rig != NIL && x <= tx){
          find(T[v].rig, sx, tx, sy, ty, depth+1, ans);
        }
      }
      else{
        if(T[v].lef != NIL && sy <= y){
          find(T[v].lef, sx, tx, sy, ty, depth+1, ans);
        }
        if(T[v].rig != NIL && y <= ty){
          find(T[v].rig, sx, tx, sy, ty, depth+1, ans);
        }
      }
    }
};
//-----------------------------------------

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

  ll n;
  cin >> n;
  kD_tree tree(n);
  REP(i,n){
    ll x, y;
    cin >> x >> y;
    tree.P[i] = {i,x,y};
  }
  ll q;
  cin >> q;
  ll root = tree.make_tree(0,n,0);
  vector<kD_tree::Point> ans;
  REP(i,q){
    ans.clear();
    ll sx, tx, sy, ty;
    cin >> sx >> tx >> sy >> ty;
    tree.find(root, sx, tx, sy, ty, 0, ans);
    sort(ALL(ans));
    REP(i,SZ(ans)) cout << ans[i].id <<endl;
    cout << endl;
  }


  return 0;
}




Measured memory_bytes: 29472