N = int(input()) l = [input() for i in range(N)] M = int(input()) l1 = [input() for i in range(M)] ans = [0 for i in range(M)] for i in l: A, B = map(int, i.split()) for j in range(M): X, Y = map(int, l1[j].split()) if X <= A and Y >= B: ans[j] += 1 K = max(ans) if K == 0: print(0) else: for i in range(M): if K == ans[i]: print(i + 1)