N = int(input()) AB = [list(map(int, input().split())) for i in range(N)] M = int(input()) m = 1 ans = [] for i in range(M): x, y = map(int, input().split()) z = 0 for a, b in AB: if x <= a and y >= b: z += 1 if m < z: m = z ans = [i + 1] elif m == z: ans += [i + 1] if ans: print(*ans, sep='\n') else: print(0)