N = int(input()) member = [tuple(map(int, input().split())) for _ in range(N)] M = int(input()) cnt = [0 for _ in range(M)] mentaiko = [tuple(map(int, input().split())) for _ in range(M)] for a, b in member: for i in range(M): x, y = mentaiko[i] if x <= a and y >= b: cnt[i] += 1 m = max(cnt) if m == 0: print(0) else: for i in range(N): if cnt[i] == m: print(i + 1)