#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct segTreeRangeFreq {
    int n;
    vector<vector<PII>> dat;
    // 初期化 O(NlogN)
    segTreeRangeFreq() {}
    segTreeRangeFreq(vector<vector<PII>> v) {
        n = 1; while(n < (ll)v.size()) n *= 2;
        dat.resize(2*n-1);
        REP(i, v.size()) dat[i+n-1] = v[i];
        for(int i=n-2; i>=0; --i) {
            dat[i].resize(dat[i*2+1].size() + dat[i*2+2].size());
            merge(ALL(dat[i*2+1]), ALL(dat[i*2+2]), dat[i].begin());
        }
    }
    // [a, b) のx以上y以下の個数を返す O(log^2N)
    vector<int> query(int a, int b, ll x, ll y, int k, int l, int r) {
        if(b <= l || r <= a) return {};
        if(a <= l && r <= b) {
            vector<int> ret;
            ll itr1 = lower_bound(ALL(dat[k]), PII(x, -LLINF)) - dat[k].begin();
            ll itr2 = upper_bound(ALL(dat[k]), PII(y, LLINF)) - dat[k].begin();
            // cout << "itr1=" << itr1 << " itr2=" << itr2 << endl;
            FOR(i, itr1, itr2) ret.push_back(dat[k][i].second);
            // cout << "l=" << l << " r=" << r << " dat=" << dat[k] << " ret=" << ret << endl;
            return ret;
        }
        vector<int> vl = query(a, b, x, y, k*2+1, l, (l+r)/2);
        vector<int> vr = query(a, b, x, y, k*2+2, (l+r)/2, r);
        for(auto i: vr) vl.push_back(i);
        return vl;
    }
    vector<int> query(int a, int b, ll x, ll y) { return query(a, b, x, y, 0, 0, n); }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];
    ll q;
    cin >> q;
    vector<ll> sx(q), tx(q), sy(q), ty(q);
    REP(i, q) cin >> sx[i] >> tx[i] >> sy[i] >> ty[i];

    vector<ll> vs(x);
    REP(i, q) {
        vs.push_back(sx[i]);
        vs.push_back(tx[i]);
    }
    sort(ALL(vs));
    vs.erase(unique(ALL(vs)), vs.end());
    // cout << "vs:" << vs << endl;

    vector<vector<PII>> v(vs.size());
    REP(i, n) {
        x[i] = lower_bound(ALL(vs), x[i]) - vs.begin();
        v[x[i]].push_back({y[i], i});
    }
    REP(i, vs.size()) sort(ALL(v[i]));
    // REP(i, vs.size()) cout << v[i] << endl;
    segTreeRangeFreq seg(v);

    REP(i, q) {
        sx[i] = lower_bound(ALL(vs), sx[i]) - vs.begin();
        tx[i] = lower_bound(ALL(vs), tx[i]) - vs.begin();
        auto ret = seg.query(sx[i], tx[i]+1, sy[i], ty[i]);
        sort(ALL(ret));
        for(auto j: ret) cout << j << endl;
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 221388