N = int(input()) ABs = [[int(j) for j in input().split()] for i in range(N)] M = int(input()) XYs = [[int(j) for j in input().split()] for i in range(M)] def be_wanted(A, B, X, Y): if X <= A and B <= Y: return True else: return False def argmax_s(X): tmp = -99999 for i, x in enumerate(X): if tmp < x: tmp = x res = [i] elif tmp == x: res.append(i) return res point = [0 for i in range(M)] for i, xy in enumerate(XYs): for ab in ABs: if be_wanted(ab[0], ab[1], xy[0], xy[1]): point[i] += 1 if sum(point) == 0: print(0) else: for i in (argmax_s(point)): print(i+1)