### BUGGY CODE ###

import sys

i_f = sys.stdin

n = int(i_f.readline())

T = []
for i in range(n):
    x, y = map(int, i_f.readline().split())
    # [2] is input number.
    # [3] is left node, and [4] is right node.
    T.append([x, y, i, None, None])

def make2DTree(l, r, depth):
    if not l < r:
        return None

    mid = (l + r) // 2

    axis = depth % 2

    t_lr = T[l:r]
    t_lr.sort(key=lambda n: n[axis])
    T[l:r] = t_lr

    T[mid][3] = make2DTree(l, mid, depth + 1)
    T[mid][4] = make2DTree(mid + 1, r, depth + 1)

    return T[mid]


make2DTree(0, n, 0)

root_node = T[n // 2]

Ans = []

def range_search(sx, tx, sy, yx):
    ans = []
    
    def _find(node, sx, tx, sy, ty, depth):
        x = node[0]
        y = node[1]

        if sx <= x <= tx and sy <= y <= ty:
            ans.append(node[2])

        if depth % 2 == 0:
            if node[3] and sx <= x:
                _find(node[3], sx, tx, sy, ty, depth + 1)
            if node[4] and x <= tx:
                _find(node[4], sx, tx, sy, ty, depth + 1)
        else:
            if node[3] and sy <= y:
                _find(node[3], sx, tx, sy, ty, depth + 1)
            if node[4] and y <= ty:
                _find(node[4], sx, tx, sy, ty, depth + 1)

    _find(root_node, sx, tx, sy, ty, 0)

    if ans:
        ans.sort()
        Ans.extend(ans)
    Ans.append('')


q = int(i_f.readline())


for l in i_f:
    sx, tx, sy, ty = map(int, l.split())
    range_search(sx, tx, sy, ty)

print('\n'.join(map(str, Ans)))

### FIXED CODE ###

import sys, math
from operator import itemgetter
from bisect import bisect_left, bisect_right

f_i = sys.stdin

def main():
    n = int(f_i.readline())
    
    lx = []
    ly = []
    li = []
    for i in range(n):
        x, y = map(int, f_i.readline().split())
        lx.append(x)
        ly.append(y)
        li.append(i)

    x_width = max(lx) - min(lx)
    y_width = max(ly) - min(ly)
    if x_width > y_width:
        P = list(zip(lx, ly, li))
    else:
        P = list(zip(ly, lx, li))
    P.sort()

    interval = int(math.sqrt(n))

    low = [v1 for v1, v2, i in P[::interval]]
    high = [v1 for v1, v2, i in P[interval - 1::interval]] + [float('inf')]

    S = []
    v2_sec_list = []
    for i in range(0, n, interval):
        si = P[i:i + interval]
        si.sort(key=itemgetter(1))
        v2_s = [p[1] for p in si]
        v2_sec_list.append(v2_s)
        S.append(si)

    A = []

    q = f_i.readline()

    for l in f_i:
        sx, tx, sy, ty = map(int, l.split())
        a = []
        if x_width > y_width:
            for i in range(bisect_left(high, sx), bisect_right(low, tx)):
                v = S[i]
                k = v2_sec_list[i]
                for j in range(bisect_left(k, sy), bisect_right(k, ty)):
                    if sx <= v[j][0] <= tx:
                        a.append(v[j][2])
        else:
            for i in range(bisect_left(high, sy), bisect_right(low, ty)):
                v = S[i]
                k = v2_sec_list[i]
                for j in range(bisect_left(k, sx), bisect_right(k, tx)):
                    if sy <= v[j][0] <= ty:
                        a.append(v[j][2])
        
        if a:
            a.sort()
            A.extend(a)
        A.append('')

    print('\n'.join(map(str, A)))

main()