import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

struct Point {
    int x, y;
    int index;
};
class RangeTree {
    class Node {
        Node parent;
        Node left, right;
        int left_x, right_x;
        int[] ys;
        override string toString() const {
            return format("([%s,%s] -> %s)", left_x, right_x, ys);
        }
    }
    Point[] P;
    Node root;
    Node construct(int[] ps) {
        auto n = new Node;
        n.left_x = P[ps.front].x;
        n.right_x = P[ps.back].x;
        if(ps.length <= 1024) {
            n.ys = ps.sort!((i, j)=>(P[i].y < P[j].y)).array;
            return n;
        }
        auto l = construct(ps[0 .. $ / 2]);
        auto r = construct(ps[$ / 2 .. $]);
        l.parent = n;
        r.parent = n;
        n.left = l;
        n.right = r;
        auto li = 0, ri = 0;
        while (true) {
            if (li >= l.ys.length && ri >= r.ys.length) break;
            if (li >= l.ys.length) n.ys ~= r.ys[ri++];
            else if (ri >= r.ys.length) n.ys ~= l.ys[li++];
            else {
                n.ys ~= (P[l.ys[li]].y < P[r.ys[ri]].y ? l.ys[li++] : r.ys[ri++]);
            }
        }
        return n;
    }
    this(Point[] ps) {
        this.P = ps.dup;
        auto ys = iota(0, ps.size, 1).array.sort!((i, j) => P[i].x < P[j].x).array;
        this.root = construct(ys);
    }

    /* (sx <= x <= gx && sy <= y <= gy)????????§??????(x, y)??§?±?esult???????????\??§??????. ??¢????????¢?????????????±???¨??¢???*/
    int[] query(int sx, int sy, int gx, int gy) {
        int[] result;
        void f(Node cur_root) {
            if (gx < cur_root.left_x || cur_root.right_x < sx) {
                // do nothing
            } else if (sx <= cur_root.left_x && cur_root.right_x <= gx) {
                int[] ys = cur_root.ys;
                result ~= ys.map!((i)=>tuple(P[i].y, i)).assumeSorted.upperBound(tuple(sy, int.min)).lowerBound(tuple(gy + 1, int.min)).map!((x)=>x[1]).array;
                //result ~= ys.assumeSorted!((i, j) => (P[i].y < P[j].y)).upperBound(sy).lowerBound(gy + 1).array;
            } else {
                if(cur_root.left is null || cur_root.right is null) {
                    foreach (i; cur_root.ys.map!((i)=>tuple(P[i].y, i)).assumeSorted.upperBound(tuple(sy, int.min)).lowerBound(tuple(gy + 1, int.min)).map!((x)=>x[1])) {
                        auto p = P[i];
                        if (sx <= p.x && p.x <= gx && sy <= p.y && p.y <= gy) {
                            result ~= i;
                        }
                    }
                } else {
                    f(cur_root.left);
                    f(cur_root.right);
                }
            }
        }
        f(root);
        return result;
    }
}

void main() {
    int N = readln.chomp.to!int;
    auto P = new Point[N];
    foreach (int i; 0 .. N) {
        readf("%s %s\n", &P[i].x, &P[i].y);
        P[i].index = i;
    }
    auto tree = new RangeTree(P);
    int Q = readln.chomp.to!int;
    foreach (_; 0 .. Q) {
        int sx, sy, gx, gy; readf("%s %s %s %s\n", &sx, &gx, &sy, &gy);
        auto result = tree.query(sx, sy, gx, gy);
        sort(result);
        foreach (r; result) {
            writeln(r);
        }
        writeln("");
    }
}

Measured memory_bytes: 38564