N = int(input()) AB = [list(map(int, input().split())) for i in range(N)] M = int(input()) XY = [list(map(int, input().split())) for i in range(M)] cnt = [0] * M for i in range(N): A, B = AB[i] for j in range(M): X, Y = XY[j] if X <= A and B <= Y: cnt[j] += 1 maxcnt = max(cnt) if maxcnt == 0: print(0) exit() for i in range(M): if cnt[i] == maxcnt: print(i + 1)