N = int(input()) D = [] for _ in range(N): A, B = map(int, input().split()) D.append([A, B]) M = int(input()) A = [0 for _ in range(M)] for i in range(M): X, Y = map(int, input().split()) for L in D: if X <= L[0] and Y >= L[1]: A[i] += 1 for i in range(M): if A[i] == max(A): print(i+1)