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

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto kdTree = new KDTree();

    int n = readint();
    for (int i = 0; i < n; i++) {
        auto xy = readints();
        kdTree.insert(new Point(i, xy[0], xy[1]));
    }

    int q = readint();
    for (int i = 0; i < q; i++) {
        auto ss = readints();
        int sx = ss[0], tx = ss[1];
        int sy = ss[2], ty = ss[3];
        auto ans = kdTree.search(new Point(-1, sx, sy), new Point(-1, tx, ty));
        foreach (x; ans)
            writeln(x);
        writeln();
    }
}

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

    private Node root;

    void insert(Point p) {
        root = insert(root, 0, p);
    }

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

    Node insert(Node t, int d, Point p) {
        if (t is null) {
            return new Node(p);
        }

        if (cmp(d, p, t.p))
            t.l = insert(t.l, !d, p);
        else
            t.r = insert(t.r, !d, p);
        return t;
    }

    int[] search(Point ld, Point ru) {
        int[] acc;
        search(root, 0, ld, ru, acc);
        return acc;
    }

    void search(Node t, int d, Point ld, Point ru, ref int[] acc) {
        if (t is null)
            return;
        auto p = t.p;
        if (ld.x <= p.x && p.x <= ru.x && ld.y <= p.y && p.y <= ru.y) {
            acc ~= p.index;
        }
        if (!cmp(d, p, ld))
            search(t.l, !d, ld, ru, acc);
        if (!cmp(d, ru, p))
            search(t.r, !d, ld, ru, acc);
    }
}

class Point {
    immutable int index;
    immutable int x;
    immutable int y;

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