n = int(input()) nl = [list(map(int, input().split())) for _ in range(n)] m = int(input()) ml = [list(map(int, input().split())) for _ in range(m)] l = [0] * (m+1) for i, (x, y) in enumerate(ml, 1): for a, b in nl: if x <= a and y >= b: l[i] += 1 z = max(l) if z == 0: print(z) else: for i in range(len(l)): if l[i] == z: print(i)