### BUGGY CODE ###

from operator import itemgetter
import sys

def main():
    n = int(input())
    keys = map(lambda i:(map(int,sys.stdin.readline().split())),xrange(n))
    kx,ky = zip(*keys)
    keys = zip(kx,ky,xrange(n))
    keys.sort()
    id_m = len(keys)/2
    root = Node(keys[id_m][0],keys[id_m][1],keys[id_m][2])
    if id_m != 0:
        recursive_add_Node(root,keys[:id_m],1)
    if id_m+1 != len(keys):
        recursive_add_Node(root,keys[id_m+1:],1)

    q = int(input())
    for i in xrange(q):
        sx, tx, sy, ty = map(int,sys.stdin.readline().split())
        nums = []
        find(root,sx,sy,tx,ty,0,nums)
        nums.sort()
        map(lambda n:sys.stdout.write("{}\n".format(n)), nums)
        print ("")

def find(z,sx,sy,tx,ty,d,nums):
    if(sx<=z.key_x<=tx)and(sy<=z.key_y<=ty):
        nums.append(z.num)
    d += 1
    if d%2:
        if (z.left != None)and(z.key_y>=sy):
            find(z.left,sx,sy,tx,ty,d,nums)
        if (z.right != None)and(z.key_y<=ty):
            find(z.right,sx,sy,tx,ty,d,nums)
    else:
        if (z.left != None)and(z.key_x>=sx):
            find(z.left,sx,sy,tx,ty,d,nums)
        if (z.right != None)and(z.key_x<=tx):
            find(z.right,sx,sy,tx,ty,d,nums)

        

def add_Node(root,kx,ky,n):
    y = None
    x = root
    d = 0
    xy = 0
    while(x != None):
        d += 1
        xy = d%2
        y = x
        if xy == 0:
            if x.key_x > kx:
                x = x.left
            else:
                x = x.right
        else:
            if x.key_y > ky:
                x = x.left
            else:
                x = x.right
    
    z = Node(kx,ky,n)

    if xy == 0:
        if y.key_x > kx:
            y.left = z
        else:
            y.right = z
    else:
        if y.key_y > ky:
            y.left = z
        else:
            y.right = z

def recursive_add_Node(root,k,d):
    k.sort(key=itemgetter(d%2))
    len_k = len(k)
    id_m = len_k/2
    add_Node(root,k[id_m][0],k[id_m][1],k[id_m][2])
    if id_m != 0:
        recursive_add_Node(root,k[:id_m],d+1)
    if id_m+1 != len_k:
        recursive_add_Node(root,k[id_m+1:],d+1)

class Node():
    def __init__(self,x,y,n):
        self.key_x = x
        self.key_y = y
        self.num   = n
        self.left  = None
        self.right = None


if __name__ == "__main__":
    main()

### FIXED CODE ###

from sys import stdin,stdout
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right
readline = stdin.readline
 
def main():
    n = int(input())
    keys = map(lambda i: map(int,readline().split())+[i], xrange(n))
    keys.sort()

    root = int(math.sqrt(len(keys)))
 
    low = [x for x, y, i in keys[::root]]
    high = [x for x, y, i in keys[root - 1::root]] + [float('inf')]
 
    keys = [sorted(keys[i:i+root], key=itemgetter(1)) for i in range(0,len(keys),root)]
    keys_y = map(lambda k:[y for x,y,i in k], keys)

    q = int(input())
    for i in xrange(q):
        sx,tx,sy,ty = map(int,readline().split())
        
        nums = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            y = keys_y[i]
            for j in range(bisect_left(y, sy), bisect_right(y, ty)):
                if sx <= keys[i][j][0] <= tx:
                    nums.append(keys[i][j][2])
        if nums:
            nums.sort()
            map(lambda n:stdout.write("{}\n".format(n)), nums)
        print("")

if __name__ == "__main__":
    main()