using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

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

    }
    public struct Node
    {
        public int l, r;
        public Node(int l, int r)
        {
            this.l = l;
            this.r = r; 
        }
    }

    internal int n;
    Node[] T;
    public Point[] P;
    public int root;
    public List<int> A;

    public kDTree(int n)
    {
        this.n = n;
        T = new Node[n];
        P = new Point[n];
    }

    public int MakekDTree(int l, int r, int depth)
    {
        if (l >= r) return -1;

        int mid = (l + r) / 2;

        if (depth % 2 == 0) Array.Sort(P, l, r - l, new Comparer_X());
        else Array.Sort(P, l, r - l, new Comparer_Y());

        T[mid].l = MakekDTree(l, mid, depth + 1);
        T[mid].r = MakekDTree(mid + 1, r, depth + 1);

        return mid;
    }
    class Comparer_X : IComparer<Point>
    {
        public int Compare(Point a, Point b)
        {
            return a.x - b.x;
        }
    }

    class Comparer_Y : IComparer<Point>
    {
        public int Compare(Point a, Point b)
        {
            return a.y - b.y;
        }
    }
    public void Find(int v, int sx, int tx, int sy, int ty, int depth)
    {
        int x = P[v].x, y = P[v].y;
        if (sx <= x && x <= tx && sy <= y && y <= ty) A.Add(P[v].id);

        if (depth % 2 == 0)
        {
            if (T[v].l != -1 && sx <= x) Find(T[v].l, sx, tx, sy, ty, depth + 1);
            if (T[v].r != -1 && x <= tx) Find(T[v].r, sx, tx, sy, ty, depth + 1);
        }
        else
        {
            if (T[v].l != -1 && sy <= y) Find(T[v].l, sx, tx, sy, ty, depth + 1);
            if (T[v].r != -1 && y <= ty) Find(T[v].r, sx, tx, sy, ty, depth + 1);
        }
    }



}
class Program
{
    static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Program().solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();

    int n, q;
    void solve()
    {
        n = cin.nextint;
        kDTree K = new kDTree(n);
        for (int i = 0; i < n; i++)
        {
            K.P[i]= new kDTree.Point(i, cin.nextint, cin.nextint); 
        }
        K.root = K.MakekDTree(0, n, 0);
        q = cin.nextint;

        for (int i = 0; i < q; i++)
        {
            K.A = new List<int>();
            K.Find(K.root, cin.nextint, cin.nextint, cin.nextint, cin.nextint, 0);
            K.A.Sort();
            foreach (var id in K.A)
            {
                Console.WriteLine(id);
            }
            Console.WriteLine();
        }
        
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return Console.ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 24004