// Original C++ solution (slower):
#include<iostream>

using namespace std;

#include<cstdio>       // k-D_tree. (k = 2)

#include<algorithm>



class Point

{

public:

    int id, x, y;

    Point(){};

    Point(int no, int pos_x, int pos_y) : id(no), x(pos_x), y(pos_y) {};

    void print(){ printf("%d\n", id); }

};



bool cmp_x(const Point &P1, const Point &P2){ return P1.x < P2.x; }

bool cmp_y(const Point &P1, const Point &P2){ return P1.y < P2.y; }

bool cmp_id(const Point &P1, const Point &P2){ return P1.id < P2.id; }



class node // nodes of 2-D_tree.

{

public:

    Point *mark;

    node *less, *more;

    int depth;   // parity of depth is important.

    node() : mark(NULL), less(NULL), more(NULL), depth(0) {};

    node(Point* pos, node* l, node* m, int d) : mark(pos), less(l), more(m), depth(d) {};

};



node* make_tree(Point S[], int left, int right, int d) // recursive construction of 2-D_tree.

{

    if(left > right){ return NULL; }

    if(left == right){

        node* leaf = new node;

        *leaf = node(&S[left], NULL, NULL, d);    // arrived at leaf.

        return leaf;

    }



	if(d & 1){

		sort(S + left, S + right + 1, cmp_x);

	}else{

        sort(S + left, S + right + 1, cmp_y);

	}



    int mid = (left + right) / 2;



    node* n = new node;   // make a new node.

    n->mark = &S[mid];

    n->depth = d;

    n->less = make_tree(S, left, mid - 1, d + 1);

    n->more = make_tree(S, mid + 1, right, d + 1);



    return n;

}



int cnt;



void find(Point S[], int sx, int tx, int sy, int ty, node* kd_n)

{

    if(kd_n == NULL) return;



    if(sx <= kd_n->mark->x && kd_n->mark->x <= tx && sy <= kd_n->mark->y && kd_n->mark->y <= ty){

        S[cnt] = *(kd_n->mark);

        cnt++;

    }

    int ax = kd_n->mark->x, ay = kd_n->mark->y, d = kd_n->depth;



    if(d & 1){

        if(sx <= ax) find(S, sx, tx, sy, ty, kd_n->less);

        if(ax <= tx) find(S, sx, tx, sy, ty, kd_n->more);

    }else{

        if(sy <= ay) find(S, sx, tx, sy, ty, kd_n->less);

        if(ay <= ty) find(S, sx, tx, sy, ty, kd_n->more);

    }

}



int main()

{

    int i, pos_x, pos_y, n;

    Point P[500000], Q[100];



    scanf("%d", &n);

    for(i = 0; i < n; i++){ scanf("%d %d", &pos_x, &pos_y); P[i] = Point(i, pos_x, pos_y); }

	

    node* root;

    root = make_tree(P, 0, n - 1, 0);  // make a 2-D_tree.



    int q, sx, tx, sy, ty;

    scanf("%d", &q);

    while(q){

        cnt = 0;

        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);      // input data.

        find(Q, sx, tx, sy, ty, root);   // counting.

        sort(Q, Q + cnt, cmp_id);

        for(i = 0; i < cnt; i++){ Q[i].print(); }  // print out.

        printf("\n");

        q--;

    };



    return 0;

}

// Optimized solution to the same problem (faster):
#include<iostream>

using namespace std;

#include<cstdio>

#include<algorithm>

#include<utility>



typedef pair<pair<int, int>, int> point;



int main()

{

	point *S;

	point *T;

	int x, y, n;

	scanf("%d", &n);

	S = new point [n];

	T = new point [n];



	for(int i = 0; i < n; i++){

		scanf("%d %d", &x, &y);

		S[i] = make_pair(make_pair(x, y), i);

		T[i] = make_pair(make_pair(y, x), i);

	}

	sort(S, S + n);

	sort(T, T + n);



	int cnt;

    int Q[100];



    int sx, tx, sy, ty, q;



    scanf("%d", &q);

    while(q){

        cnt = 0;

        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);



		int x_low = lower_bound(S, S + n, make_pair(make_pair(sx, sy), 0)) - S;

		int x_high = upper_bound(S, S + n, make_pair(make_pair(tx, ty), n)) - S;

		int y_low = lower_bound(T, T + n, make_pair(make_pair(sy, sx), 0)) - T;

		int y_high = upper_bound(T, T + n, make_pair(make_pair(ty, tx), n)) - T;

		int x_width = x_high - x_low;

		int y_width = y_high - y_low;



		if(x_width < y_width){

			for(int i = x_low; i < x_high; i++){

				int y = S[i].first.second;

				if(sy <= y && y <= ty){ Q[cnt++] = S[i].second; }

			}

		}else{

			for(int i = y_low; i < y_high; i++){

				int x = T[i].first.second;

				if(sx <= x && x <= tx){ Q[cnt++] = T[i].second; }

			}

		}

        sort(Q, Q + cnt);

        for(int i = 0; i < cnt; i++){ printf("%d\n", Q[i]); }

        printf("\n");

        q--;

    };

    return 0;

}

// Fastest known solution for this problem: