import bisect def main(): N = int(input()) A, B = [], [] apndA, apndB = A.append, B.append for i in range(N): a, b = map(int, input().split()) apndA((a, i)) apndB((b, i)) M = int(input()) XY = tuple(tuple(map(int, input().split())) for _ in [0] * M) a, b = sorted(A), sorted(B) a = list(map(lambda *x: x, *a)) b = list(map(lambda *x: x, *b)) men = [0] * M for i, (x, y) in enumerate(XY): j = bisect.bisect_left(a[0], x) seta = set(a[1][j:]) j = bisect.bisect(b[0], y) setb = set(b[1][:j]) men[i] += len(seta & setb) max_ = max(men) if not max_: print(0) else: print(*[i + 1 for i, j in enumerate(men) if j == max_], sep='\n') main()