using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        public static readonly int NIL = -1;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var XY = new List<KeyValuePair<int, int>>();
            for (var i = 0; i < N; ++i)
            {
                var xy = Sarray();
                XY.Add(new KeyValuePair<int, int>((int)xy[0], (int)xy[1]));
            }
            var d2t = new D2Tree(XY);
            var Q = Sarray()[0];
            for (var i = 0; i < Q; ++i)
            {
                var sxy = Sarray();
                var sx = sxy[0];
                var tx = sxy[1];
                var sy = sxy[2];
                var ty = sxy[3];
                d2t.find((int)sx, (int)tx, (int)sy, (int)ty);
                d2t.ans.Sort();
                foreach (var a in d2t.ans)
                    WriteLine(a);
                WriteLine();
            }
            Out.Flush();
        }

        public struct Node
        {
            public int l { get; set; }
            public int r { get; set; }
            public int location { get; set; }
            public int p { get; set; }
        }
        public struct Point
        {
            public int id { get; set; }
            public int x { get; set; }
            public int y { get; set; }
            public Point(int id, int x,int y) { this.id = id; this.x = x;this.y = y; }
            //public static bool operator <(Point l, Point r) => l.id < r.id;
            //public static bool operator >(Point l, Point r) => l > r;
        }
        public class lessX : IComparer<Point>
        {
            public int Compare(Point l, Point r) => l.x - r.x;
        }
        public class lessY : IComparer<Point>
        {
            public int Compare(Point l, Point r) => l.y - r.y;
        }
        public class D2Tree
        {
            Point[] P;
            Node[] T;
            int np;
            public List<int> ans;

            public D2Tree(List<KeyValuePair<int, int>> lst)
            {
                var n = lst.Count;
                P = new Point[n];
                T = new Node[n];
                for (var i = 0; i < lst.Count; ++i)
                {
                    P[i] = new Point(i, lst[i].Key, lst[i].Value);
                    T[i] = new Node();
                }
                np = 0;
                make2DTree(0, n, 0);
            }
            int make2DTree(int l, int r, int depth)
            {
                if (r <= l) return NIL;
                var mid = (l + r) / 2;
                var t = np++;
                if (depth % 2 == 0)
                    Array.Sort(P, l, r - l, new lessX());
                else
                    Array.Sort(P, l, r - l, new lessY());
                T[t].location = mid;
                T[t].l = make2DTree(l, mid, depth + 1);
                T[t].r = make2DTree(mid + 1, r, depth + 1);

                return t;
            }
            int sx, tx, sy, ty;
            public void find(int sx, int tx, int sy, int ty)
            {
                this.sx = sx;
                this.tx = tx;
                this.sy = sy;
                this.ty = ty;
                ans = new List<int>();
                find_(0, 0);
            }
            void find_(int v, int depth)
            {
                var x = P[T[v].location].x;
                var y = P[T[v].location].y;
                if (sx <= x && x <= tx && sy <= y && y <= ty)
                {
                    //WriteLine(T[v].location + ":" + P[T[v].location].id + ",x:" + P[T[v].location].x + ",y:" + P[T[v].location].y);
                    ans.Add(P[T[v].location].id);
                }
                if (depth % 2 == 0)
                {
                    if (T[v].l != -1 && sx <= x)
                        find_(T[v].l, depth + 1);
                    if (T[v].r != -1 && x <= tx)
                        find_(T[v].r, depth + 1);
                }
                else
                {
                    if (T[v].l != -1 && sy <= y)
                        find_(T[v].l, depth + 1);
                    if (T[v].r != -1 && y <= ty)
                        find_(T[v].r, depth + 1);
                }
            }
        }
    }
}


Measured memory_bytes: 40340