N = int(input()) l = [map(int, input().split()) for i in range(N)] M = int(input()) l1 = [map(int, input().split()) for i in range(M)] ans = [0 for i in range(M)] for A, B in zip(l[0], l[1]): for j, (X, Y) in enumerate(zip(l1[0],l1[1])): 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)