N = int(input()) L = [list(map(int,input().split())) for _ in range(N)] M = int(input()) C = [0] * M for i in range(M): P, S = map(int, input().split()) T = 0 for j in range(N): if P <= L[j][0] and S >= L[j][1]: T += 1 C[i] = T if sum(C) == 0: print(0) else: for i in range(M): if C[i] == max(C): print(i + 1)