from collections import Counter import sys def D(*a, **kwa): print(*a, file=sys.stderr, **kwa) N = int(input()) AB = [list(map(int, input().split())) for _ in range(N)] M = int(input()) XY = [[i] + list(map(int, input().split())) for i in range(M)] XY.sort(key=lambda x: x[1]) c = Counter() for i in range(N): a, b = AB[i] for xy in XY: if xy[1] <= a: if xy[2] >= b: c[xy[0]] += 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')