using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Main() {
        int n = ReadInt();
        var ps = new Point[n];
        for (int i = 0; i < n; i++) {
            var xy = ReadInts();
            ps[i] = new Point(i, xy[0], xy[1]);
        }

        var kdTree = new KDTree();
        kdTree.make(ps);
        int q = ReadInt();
        for (int i = 0; i < q; i++) {
            var ss = ReadInts();
            int sx = ss[0], tx = ss[1];
            int sy = ss[2], ty = ss[3];
            var ans = kdTree.search(new Point(-1, sx, sy), new Point(-1, tx, ty));
            Array.Sort(ans);
            foreach (var a in ans)
                Console.WriteLine(a);
            Console.WriteLine();
        }

    }
}

class KDTree {
    public class Node {
        public Point p;
        public Node l, r;
        public Node(Point p) {
            this.p = p;
        }
    }

    private Node _root;

    public void make(Point[] ps) {
        _root = make(ps, 0, ps.Length, 0);
    }

    Node make(Point[] ps, int lo, int hi, int d) {
        if (lo >= hi) return null;

        if (d == 0)
            Array.Sort(ps, lo, hi - lo, new CmpX());
        else
            Array.Sort(ps, lo, hi - lo, new CmpY());

        int mid = (lo + hi) / 2;
        var node = new Node(ps[mid]);
        node.l = make(ps, lo, mid, d ^ 1);
        node.r = make(ps, mid + 1, hi, d ^ 1);
        return node;
    }

    public int[] search(Point ld, Point ru) {
        var acc = new List<int>();
        search(_root, 0, ld, ru, acc);
        return acc.ToArray();
    }

    bool cmp(int d, Point a, Point b) {
        return d != 0 ? a.x < b.x : a.y < b.y;
    }

    public void search(Node t, int d, Point ld, Point ru, List<int> acc) {
        if (t == null) return;

        var p = t.p;
        if (ld.x <= p.x && p.x <= ru.x && ld.y <= p.y && p.y <= ru.y) {
            acc.Add(p.index);
        }
#if false
        if (!cmp(d, p, ld))
            search(t.l, d ^ 1, ld, ru, acc);
        if (!cmp(d, ru, p))
            search(t.r, d ^ 1, ld, ru, acc);
#else
        if (d == 0) {
            if (ld.x <= p.x) search(t.l, d ^ 1, ld, ru, acc);
            if (p.x <= ru.x) search(t.r, d ^ 1, ld, ru, acc);
        }
        else {
            if (ld.y <= p.y) search(t.l, d ^ 1, ld, ru, acc);
            if (p.y <= ru.y) search(t.r, d ^ 1, ld, ru, acc);
        }
#endif
    }
}

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

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

public class Point {
    public int index;
    public int x, y;
    public Point(int index, int x, int y) {
        this.index = index;
        this.x = x;
        this.y = y;
    }
}