def main(): N = int(input()) AB = tuple(tuple(map(int, input().split())) for _ in [0] * N) M = int(input()) XY = tuple(tuple(map(int, input().split())) for _ in [0] * M) men = {i:0 for i in range(M + 1)} ab = sorted(AB, reverse=True) xy = sorted(XY) for i, (x, y) in enumerate(xy): for a, b in ab: if a >= x: if b <= y: men[i+1] += 1 else: break maxv = max(men.values()) if maxv == 0: print(0) else: for i in [key for key in men if men[key] == maxv]: print(i) main()