N = int(input()) lsAB = [tuple(map(int,input().split())) for i in range(N)] M = int(input()) lsXY = [tuple(map(int,input().split())) for i in range(M)] cnt = [0]*(M) for i in range(N): a,b = lsAB[i] for j in range(M): x,y = lsXY[j] if x <= a and y >= b: cnt[j] += 1 maxj = max(cnt) if maxj == 0: print(0) exit() for i in range(M): if cnt[i] == maxj: print(i+1)