### BUGGY CODE ###

import sys

i_f = sys.stdin

n = int(i_f.readline())

class kdTreeNode:
    def __init__(self, input_num, x, y):
        self.input_num = input_num
        self.x = x
        self.y = y
        self.left = None
        self.right = None

T = [kdTreeNode(i, *map(int, i_f.readline().split())) for i in range(n)]

def make2DTree(l, r, depth):
    if l >= r:
        return None

    mid = (l + r) // 2

    if depth % 2 == 0:
        T[l:r] = sorted(T[l:r], key=lambda n: n.x)
    else:
        T[l:r] = sorted(T[l:r], key=lambda n: n.y)

    T[mid].left = make2DTree(l, mid, depth + 1)
    T[mid].right = make2DTree(mid + 1, r, depth + 1)

    return mid


make2DTree(0, n, 0)

Ans = []

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

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

        if depth % 2 == 0:
            if node.left != None and sx <= x:
                _find(node.left, sx, tx, sy, ty, depth + 1)
            if node.right and x <= tx:
                _find(node.right, sx, tx, sy, ty, depth + 1)
        else:
            if node.left != None and sy <= y:
                _find(node.left, sx, tx, sy, ty, depth + 1)
            if node.right and y <= ty:
                _find(node.right, sx, tx, sy, ty, depth + 1)

    _find(v, sx, tx, sy, ty, 0)
    
    if ans:
        ans.sort()
        Ans.extend(ans)
        Ans.append('')
    else:
        Ans.append('')


q = int(i_f.readline())

v = n // 2

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

print(*Ans, sep='\n')

### 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()