from collections import Counter N = int(input()) AB = [list(map(int, input().split())) for _ in range(N)] M = int(input()) XY = [list(map(int, input().split())) for _ in range(M)] XY.sort() c = Counter() for i in range(N): a, b = AB[i] for j in range(M): x, y = XY[j] if x <= a: if y >= b: c[j] += 1 else: break if len(c) == 0: ans = [0] else: ma = max(c.values()) ans = sorted(k+1 for k, v in c.items() if v==ma) print(*ans, sep='\n')