#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

typedef pair<int, int> pii;

using namespace std;

int D;

struct OwnNode
{
	int x, y;
	int index;
	int right;
	int left;

	OwnNode() :x(-1), y(-1), index(-1), right(-1), left(-1){}
	OwnNode(int x, int y) : x(x), y(y) {}

	bool operator<(const OwnNode& n)const
	{
		if (D % 2 == 0)
		{
			return x < n.x;
		}
		else
		{
			return y < n.y;
		}
	}
	bool operator>(const OwnNode& n)const
	{
		if (D % 2 == 0)
		{
			return x > n.x;
		}
		else
		{
			return y > n.y;
		}
	}
};

OwnNode nodes[500000];


void find(int index,OwnNode& ld, OwnNode& ru, int d, vector<int>& v)
{
	if (ld.x <= nodes[index].x&&nodes[index].x <= ru.x&&ld.y <= nodes[index].y&&nodes[index].y <= ru.y)
	{
		v.push_back(nodes[index].index);
	}

	if (d % 2 == 0)
	{
		if (ld.x <= nodes[index].x)
		{
			if (nodes[index].left != -1)
			{
				find(nodes[index].left, ld, ru, d + 1, v);
			}
		}
		if (nodes[index].x <= ru.x)
		{
			if (nodes[index].right != -1)
			{
				find(nodes[index].right, ld, ru, d + 1, v);
			}
		}
	}
	else
	{
		if (ld.y <= nodes[index].y)
		{
			if (nodes[index].left != -1)
			{
				find(nodes[index].left, ld, ru, d + 1, v);
			}
		}
		if (nodes[index].y <= ru.y)
		{
			if (nodes[index].right != -1)
			{
				find(nodes[index].right, ld, ru, d + 1, v);
			}
		}
	}
}

int BuildKDTree(int s, int e, int d)
{
	int m = (s + e) / 2;
	D = d;
	nth_element(nodes + s, nodes + m, nodes + e + 1);
	nodes[m].left = m == s ? -1 : BuildKDTree(s, m - 1, d + 1);
	nodes[m].right = m == e ? -1 : BuildKDTree(m + 1, e, d + 1);
	return m;
}

int main()
{
	int n, q;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		nodes[i].x = x;
		nodes[i].y = y;
		nodes[i].index = i;
	}

	int root = BuildKDTree(0, n - 1, 0);

	scanf("%d", &q);

	for (int i = 0; i < q; i++)
	{
		int x1, y1, x2, y2;
		scanf("%d %d %d %d", &x1, &x2, &y1, &y2);
		OwnNode n1(x1, y1), n2(x2, y2);
		vector<int> v;
		find(root,n1, n2, 0, v);
		sort(v.begin(), v.end());
		for (auto& n : v)
		{
			cout << n << endl;
		}
		cout << endl;
	}

	return 0;
}


