#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

// https://onlinejudge.u-aizu.ac.jp/solutions/problem/DSL_2_C/review/2997047/s1230149/C++14
class KDT {
public:
    typedef long long ll; /*型に注意!!!!*/
    struct node {
        vector<ll> point;
        int l, r;

        node() {}

        node(vector<ll> point) : point(point) { l = r = -1; }
    };

    int K;// K:次元数
    vector<vector<ll> > P;// それぞれの要素はK+1個(各次元の値と固有ID)
    vector<node> G;
    int ok = 0;

    KDT(int K = 2) : K(K), ok(0) {};

    void add_point(vector<ll> a/*座標*/) {
        static int id = 0;
        if ((int) a.size() < K + 1) a.push_back(id++);
        assert((int) a.size() == K + 1);
        P.push_back(a);
    }

    int build(int depth = 0, int l = 0, int r = -2) {
        if (r == -2) r = (int) P.size() - 1, ok = 1;
        if (l > r) return -1;
        int D = depth % K; // D:ソートする基準の次元
        sort(P.begin() + l, P.begin() + r + 1, [&](const vector<ll> &A, const vector<ll> &B) { return A[D] < B[D]; });

        int m = (l + r) / 2, res = G.size();
        G.push_back(node(P[m]));
        int vl = build(depth + 1, l, m - 1);
        int vr = build(depth + 1, m + 1, r);
        G[res].l = vl;
        G[res].r = vr;
        return res;
    }

    vector<vector<ll> > points;//searchの座標集合と固有ID
    void search(int x, int depth, const vector<ll> &ld, const vector<ll> &ru) {
        if (P.empty()) return;
        bool f = true;
        for (int i = 0; i < K; i++)
            if (G[x].point[i] < ld[i] || ru[i] < G[x].point[i]) f = false;

        if (f) points.push_back(G[x].point);

        int D = depth % K;// D:ソートする基準の次元
        if (G[x].point[D] <= ru[D] && G[x].r != -1) search(G[x].r, depth + 1, ld, ru);
        if (ld[D] <= G[x].point[D] && G[x].l != -1) search(G[x].l, depth + 1, ld, ru);
    }


    //[0,K)の要素が座標,K番目の要素が固有IDになっている。
    vector<vector<ll> > search(vector<ll> ld/*左下*/, vector<ll> ru/*右上*/) {
        assert(ok);
        points.clear();
        search(0, 0, ld, ru);
        return points;
    }
};


int main() {

    int n;
    cin >> n;
    KDT kdTree;
    rep(i, n) {
        int x, y;
        scanf("%d%d", &x, &y);
        kdTree.add_point({x, y});
    }

    kdTree.build();;

    int q;
    cin >> q;
    rep(i, q) {
        int sx, tx, sy, ty;
        scanf("%d%d%d%d", &sx, &tx, &sy, &ty);
        auto point = kdTree.search({sx, sy}, {tx, ty});

        vector<int> ans;
        for (auto &p:point) ans.push_back(p.back());
        sort(ans.begin(), ans.end());
        for (int i : ans) printf("%d\n", i);
        printf("\n");
    }

}



Measured memory_bytes: 60020