n = int(input()) members = sorted([ list(map(int, input().split())) for _ in range(n)], key=lambda x:-x[0]) m = int(input()) mentaiko = [0] * m for i in range(m): x, y = map(int, input().split()) for price, hot in members: if x <= price and y >= hot: mentaiko[i] += 1 kiseki = sorted([i + 1 for i, x in enumerate(mentaiko) if x == max(mentaiko) and x != 0]) if kiseki == []: print(0) else: print(*kiseki, sep="\n")