### BUGGY CODE ###

import math
from collections import deque 
from operator import itemgetter

class twodtree:
    #@profile
    def __init__(self, data):
        self.data = [None] * (1 << (int(math.log(len(data), 2)) + 1))

        que = deque([(0,0,len(data) - 1,1)])
        key = itemgetter(0,1),itemgetter(1,0)
        while len(que):
            k, l, r, i = que.popleft()
            if l > r:continue
            if l == r:
                self.data[i] = data[l]
                continue

            m = (l + r) // 2
            
            que.append((k^1,l,m - 1,2 * i))
            que.append((k^1,m + 1,r,2 * i + 1))
            
            while True:
                # ?????? pertition inline?±????
                index = (l + r) // 2
                value = key[k](data[index])
                data[index], data[r] = data[r], data[index]
                n = l
                for j in range(l, r):
                    if key[k](data[j]) < value:
                        data[n], data[j] = data[j], data[n]
                        n += 1
                data[r], data[n] = data[n], data[r]
                # ?????? pertition inline?±????

                if m == n:
                    break
                elif m <  n:
                    r = n - 1
                else:
                    l = n + 1
            self.data[i] = data[m]

    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

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

main()

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