// AOJ DSL_2_C Range Search (kD Tree)
// 2018.5.16 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	if (c == '-') { c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define MAX_N  500005

struct KdNode;
typedef struct KdNode *KdTree;
struct KdNode { int id; int Data[2]; KdTree Left, Right; };

struct KdNode buf[MAX_N]; int sz;
KdTree T;

int ans[102], len;

KdTree recIns(int id, int *Item, KdTree T, int Level)
{
	if (T == NULL) {
		T = buf+sz++;
		T->Left = T->Right = NULL;
		T->id = id, T->Data[0] = Item[0], T->Data[1] = Item[1];
	} else if (Item[Level] < T->Data[Level])
		T->Left  = recIns(id, Item, T->Left , !Level);
	else
		T->Right = recIns(id, Item, T->Right, !Level);
	return T;
}

KdTree insert(int id, int *Item, KdTree T)
{
	return recIns(id, Item, T, 0);
}

// Print items satisfying
// Low[ 0 ] <= Item[ 0 ] <= High[ 0 ] and
// Low[ 1 ] <= Item[ 1 ] <= High[ 1 ]

void recPrintRange(int *Low, int *High, KdTree T, int Level)
{
	if (T != NULL) {
		if (Low[0] <= T->Data[0] &&	T->Data[0] <= High[0] &&
			Low[1] <= T->Data[1] &&	T->Data[1] <= High[1]) {
			ans[len++] = T->id;
		}

		if (Low[Level] <= T->Data[Level])
			recPrintRange(Low, High, T->Left, !Level);
		if (High[ Level ] >= T->Data[Level])
			recPrintRange(Low, High, T->Right, !Level);
	}
}

void PrintRange(int *Low, int *High, KdTree T)
{
	recPrintRange(Low, High, T, 0);
}

int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }

int main()
{
	int n, q, i;
	int v[2], s[2], t[2];

	T = NULL, sz = 1;
	n = in();
	for (i = 0; i < n; i++) {
		v[0] = in(), v[1] = in();
		T = insert(i, v, T);
	}

	q = in();
	while (q--) {
		s[0] = in(), t[0] = in();
		s[1] = in(), t[1] = in();
		len = 0;
		PrintRange(s, t, T);
		qsort(ans, len, sizeof(int), cmp);
		for (i = 0; i < len; i++) out(ans[i]);
		pc('\n');
	}
}
