#include<stdio.h>
#include<stdlib.h>
#include <string.h> 
#define NIL NULL
#define FREE 0
#define SHARE 1

struct point{
	int x, y, id;
};

struct _node{
	struct point p;
	struct _node *left;
	struct _node *right;
};

struct rect{
	int x1, y1, x2, y2;
};

struct _binT{
	int key;
	int status;
	struct _binT *left;
	struct _binT *right;
};

typedef struct _node * node;
typedef struct _binT * binT;

const int MAX_N = 500005;
struct point p[500005];

node head, z;
binT root;

void binTreeinsert (int key ){

	binT prev = NIL, cur = NIL;

	if (root == NIL || root->status == FREE ){
		root = malloc (sizeof (struct _binT ) );
		root->key = key; root->status = SHARE; root->left = NIL; root->right = NIL;
		return;
	} // end if

	cur = root;
	while (cur != NIL ){
		prev = cur; 
		if (key < cur->key ){
			cur = cur->left;
		}else{
			cur = cur->right;
		} // end if
	} // end while
	cur = malloc (sizeof (struct _binT ) );
	cur->key = key; cur->status = SHARE; cur->left = NIL; cur->right = NIL;

	if (cur->key < prev->key ){
		prev->left = cur;
	}else{
		prev->right = cur;
	} // end if		
}

void disp (binT u ){
	if (u == NIL ) return;
	disp (u->left );
	printf ("%d\n", u->key );
	disp (u->right );
}

void deletebinT (binT u ){
	if (u == NIL ) return;
	deletebinT (u->left );
	deletebinT (u->right );
	u->status = FREE;
	free (u );
}

void tree2Dinsert (struct point p ){

	node f, t;
	int d, td;

	for (d = 0, t = head; t != z; d = !d ){
		td = (d ? (p.x < t->p.x ) : (p.y < t->p.y ) );
		f = t;
		t = (td ? t->left : t->right );
	} // end for
	
	t = malloc (sizeof (struct _node ) );
	t->p = p; t->left = z; t->right = z;

	if (td )
		f->left = t;
	else
		f->right = t;
}

void preprocess (int n ){

	int i;
	p[0].x = 0; p[0].y = 0; p[0].id = -1;

	z = malloc (sizeof (struct _node ) );
	z->left = z; z->right = z; z->p = p[0];

	head = malloc (sizeof (struct _node ) );
	head->left = z; head->right = z; head->p = p[0];

	for (i = 1; i <= n; i++ ) tree2Dinsert (p[i] );
}

int insiderect (struct point p, struct rect range ){

	return ((range.x1 <= p.x && p.x <= range.x2 )
		&& (range.y1 <= p.y && p.y <= range.y2 ) );
}

int handle (struct point p ){
	binTreeinsert (p.id );
}

void tree2drange (node t, struct rect range, int d ){
	int t1, t2, tx1, tx2, ty1, ty2;
	if (t == z ) return;
	tx1 = (range.x1 < t->p.x );
	tx2 = (t->p.x <= range.x2 );
	ty1 = (range.y1 < t->p.y );
	ty2 = (t->p.y <= range.y2 );
	t1  = (d ? tx1 : ty1 );
	t2  = (d ? tx2 : ty2 );
	if (t1 ) tree2drange (t->left, range, !d );
	if (insiderect (t->p, range ) )
		if (t != head ) handle (t->p );
	if (t2 ) tree2drange (t->right, range, !d );
}

int main()
{
	int i, j, n, q, x, y, sx0, tx0, sy0, ty0;

	for (i = 0; i < MAX_N; i++ ) p[i].x = 0, p[i].y = 0, p[i].id = 0;

	scanf ("%d", &n );
	for (i = 1; i <= n; i++ ){
		scanf ("%d %d", &x, &y );
		p[i].x = x, p[i].y = y; p[i].id = i-1;
	} // end rep
	preprocess (n );

	scanf ("%d", &q );
	for (i = 0; i < q; i++ ){
		scanf ("%d %d %d %d", &sx0, &tx0, &sy0, &ty0 );
		struct rect r; r.x1 = sx0, r.y1 = sy0, r.x2 = tx0, r.y2 = ty0;
		tree2drange (head, r, 0 );
		disp (root );
		printf ("\n" );
		deletebinT (root );
	} // end rep
		
	return 0;
}