using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;

namespace kensyuday1
{


	struct Point{
		public int id;
		public int x;
		public int y;
		//public Point(int id, int x, int y){
		//	this.id = id; this.x = x; this.y = y;
		//}

		//public void print(){
		//	Console.WriteLine (id);
		//}

	}

	struct Node{
		public int location;
		public int p, l, r;
	}



	class MainClass
	{


		public static void Main (string[] args)
		{


			Kdtree kd = new Kdtree();

			int x, y; //x??§?¨????y??§?¨???¨

			kd.N = int.Parse(Console.ReadLine());

			//??????????????????
			for (int i = 0; i < kd.N; i++) {
				string[] str = Console.ReadLine ().Split (' ');
				x = int.Parse (str [0]);
				y = int.Parse (str [1]);
				//kd.P [i] = new Point (i, x, y);
				kd.P [i].id = i;
				kd.P [i].x = x;
				kd.P [i].y = y;

				kd.T [i] = new Node ();
				kd.T [i].l = kd.T [i].r = kd.T [i].p = -1;
			}

			//kD??¨????§????
			kd.makekDTree (0, kd.N);


			StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
			Console.SetOut(sw);


			//????????????
			kd.M = int.Parse (Console.ReadLine());
			int sx, tx, sy, ty;
			for (int i = 0; i < kd.M; i++) {
				string[] str = Console.ReadLine ().Split (' ');
				sx = int.Parse (str[0]);
				tx = int.Parse (str[1]);
				sy = int.Parse (str[2]);
				ty = int.Parse (str[3]);

				List<int> ans = new List<int> ();


				kd.findkd (0, sx, tx, sy, ty, 0, ans);
				ans.Sort ();
				foreach (int a in ans) {
					Console.WriteLine (a);
				}
				Console.WriteLine ("");
			}


			Console.Out.Flush();



		}


	}


	class Kdtree{
		const int MAX = 1000000;  //?????§???????????°
		const int NIL = -1;

		public int N,M; //??\?????°
		//public int t; 
		public int np = 0;
		public Point[] P = new Point[MAX]; //??????
		public Node[] T = new Node[MAX]; //??????
		int tmpx,tmpy;


		//X???????????¨?????????
		public class CompX : IComparer<Point>
		{
			public int Compare(Point p1, Point p2)
			{
				return p1.x - p2.x;
			}
		}
		//Y???????????¨?????????
		public class CompY : IComparer<Point>
		{
			public int Compare(Point p1, Point p2)
			{
				return p1.y - p2.y;
			}
		}

		// kd??¨????§????
		public int makekDTree(int l, int r, int depth=0){
			if (!(l < r)) {
				return NIL;
			}

			//????´????l??????r?????§???????????????
			if (depth % 2 == 0) {
				Array.Sort(P, l, r-l, new CompX());
			} else {
				Array.Sort(P, l, r-l, new CompY());
			}


			int mid = (l+r)/2; //????´???°?????????(??????)

			int t = np;
			np++;
			T [t].location = mid;  //??????????????????????????????
			T [t].l = makekDTree (l, mid, depth+1);  //??????????????¨??????
			T [t].r = makekDTree (mid+1, r, depth+1); //??????????????¨??????

			return t;
		}

		//kd??¨?????¢?´¢
		public void findkd(int v, int sx, int tx, int sy, int ty, int depth, List<int> ans){
			tmpx = P [T[v].location].x;
			tmpy = P [T[v].location].y;


			if(sx <= tmpx && tmpx <= tx && sy <= tmpy && tmpy <= ty){
				ans.Add (P[T[v].location].id);
			}

			if (depth % 2 == 0) {
				if (T [v].l != NIL && sx <= tmpx) {
					findkd (T [v].l, sx, tx, sy, ty, depth + 1, ans);
				}
				if (T [v].r != NIL && tmpx <= tx) {
					findkd (T [v].r, sx, tx, sy, ty, depth + 1, ans);
				}
			} else {
				if (T [v].l != NIL && sy <= tmpy) {
					findkd (T [v].l, sx, tx, sy, ty, depth + 1, ans);
				}
				if (T [v].r != NIL && tmpy <= ty) {
					findkd (T [v].r, sx, tx, sy, ty, depth + 1, ans);
				}
			}

		}







	}

}


Measured memory_bytes: 53788