/*入力
n
x0 y0
:  :
xn-1 yn-1
q
sx0 tx0 sy0 ty0
:    :   :   :
sxq-1 txq-1 syq-1 tyq-1
(0 <= n <= 500000, 0 <= q <= 20000, -INF<=x,y,ax,tx,sy,ty <= INF, sx<= tx, sy <= ty)
(各クエリについて与えられた領域内に含まれる点の数は100以下)
出力は領域内の点の番号を行ごとに出力*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 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 << endl;
    }
};

static const int MAX = 500000;
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 makeKDTree(int l, int r, int depth) {
    if(!(l < r)) return NIL;
    int mid = (l + r) >> 1;
    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 = makeKDTree(l, mid, depth+1);
    T[t].r = makeKDTree(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 and x <= tx and sy <= y and y <= ty) ans.pub(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; cin >> N;
    rep(i,N) {
        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 = makeKDTree(0, N, 0);

    int q; cin >> q;
    vector<Point> ans;
    int sx, tx, sy, ty;

    rep(i,q) {
        scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0, ans);
        sort(all(ans));
        rep(j,ans.size()) printf("%d\n",ans[j]);
		printf("\n");
    }
    return 0;
}





Measured memory_bytes: 16440