#???????????£?????§????????????????±???¨????????¢?????´?????????

def partition(data, l, r, pivotIndex, key):
    pivotValue = key(data[pivotIndex])
    data[pivotIndex], data[r] = data[r], data[pivotIndex]
    storeIndex = l
    for i in range(l, r):
        if key(data[i]) < pivotValue:
            data[storeIndex], data[i] = data[i], data[storeIndex]
            storeIndex += 1
    data[r], data[storeIndex] = data[storeIndex], data[r]
    return storeIndex

from random import randint

# partition()??§data[pivot]???m????????§???????????¨????±???????
# n != m ????????°pivot???????????????????????????????????°?????????
# pivot?????????????????????????????´????????????O(nlog(n))????????????????????§???????????????????????????
def select(data, l, r, n, key):
    while True:
        pivot = randint(l, r)
        m = partition(data, l, r, pivot, key)
        if n == m:
             return data[n]
        elif n < m:
            r = m - 1
        else:
            l = m + 1

import math
class twodtree:
    def __init__(self, data):
        self.data = [None] * (1 << (int(math.log(len(data), 2)) + 1))
    
        self.update(data,(0, 1),0,len(data)-1)
        
    def update(self, data, k, l, r, i=1):
        if l > r:
            return
        if l == r:
            self.data[i] = data[l]
            return
        
        m = (l + r) // 2
        self.data[i] = select(data, l, r, m, itemgetter(*k))

        k = (k[0],k[1])
        self.update(data,k,l,m - 1,2 * i)
        self.update(data,k,m + 1,r,2 * i + 1)
        
    def find(self, s, t, k=0, i=1):
        ret = []
        if len(self.data) <= i or self.data[i] is None:
            return ret
        if s[0] <= self.data[i][0] <= t[0] and s[1] <= self.data[i][1] <= t[1]:
            ret.append(self.data[i][2])
        
        if s[k] <= self.data[i][k]:
            ret.extend(self.find(s, t, k^1, 2 * i))
        if self.data[i][k] <= t[k]:
            ret.extend(self.find(s, t, k^1, 2 * i + 1))

        return ret

from sys import stdin
readline = stdin.readline

n = int(readline())
xyi = [list(map(int, readline().split())) + [i] for i in range(n)]


two = twodtree(xyi)
print
q = int(readline())
for sx, tx, sy, ty in [map(int, readline().split()) for _ in range(q)]:
    id = two.find((sx,sy),(tx,ty))
    id.sort()
    print('\n'.join(map(str, id)))
    print()

### FIXED CODE ###

from sys import stdin
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right
readline = stdin.readline

def main():
    xy = [tuple(map(int, readline().split())) + (i,) for i in range(int(readline()))]
    xy.sort()
    root = int(math.sqrt(len(xy)))

    low = [x for x, y, i in xy[::root]]
    high = [x for x, y, i in xy[root - 1::root]] + [float('inf')]

    xy = [sorted(xy[i:i+root], key=itemgetter(1)) for i in range(0,len(xy),root)]
    xy = [([y for x, y, i in xyi], xyi) for xyi in xy]
    for sx, tx, sy, ty in (map(int, readline().split()) for _ in range(int(readline()))):
        ret = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            k, v = xy[i]
            for i in range(bisect_left(k, sy), bisect_right(k, ty)):
                if sx <= v[i][0] <=tx:
                    ret.append(v[i][2])
        if ret:
            ret.sort()
            print('\n'.join(map(str,ret)))
        print()
main()