import bisect import heapq def main(): N = int(input()) AB = [] for i in (tuple(map(int, input().split())) for _ in [0] * N): heapq.heappush(AB, i) M = int(input()) XY = tuple(tuple(map(int, input().split())) for _ in [0] * M) a = [0] * N b = a[:] for i in range(N): a[i], b[i] = heapq.heappop(AB) men = [0] * M for i, (x, y) in enumerate(XY): j = bisect.bisect_left(a, x) b_ = b[j:] b_.sort() k = bisect.bisect(b_, y) men[i] += k max_ = max(men) if not max_: print(0) else: i = 0 try: while 1: j = men.index(max_, i) print(j + 1) i = j + 1 except: return main()