from collections import Counter n = int(input()) mem = [] mcl = [] for i in range(n): array = list(map(int, input().split())) mem.append(array) m = int(input()) men = [] for i in range(m): array = list(map(int, input().split())) men.append(array) for i in range(n): for j in range(m): if mem[i][0] >= men[j][0] and mem[i][1] <= men[j][1]: mcl.append(j) c = Counter(mcl) g = c.most_common() if len(g) == 0: print(0) for i in range(len(g)): if g[i][1] == g[0][1]: print(g[i][0] + 1)