N = int(input()) A = [0]*N B = [0]*N for i in range(N): a,b = map(int,input().split()) A[i]=a B[i]=b M = int(input()) X = [0]*M Y = [0]*M BUY = [0]*M for i in range(M): x,y = map(int,input().split()) X[i]=x Y[i]=y for n in range(N): for m in range(M): if A[n]>=X[m] and B[n]<=Y[m]: BUY[m]+=1 maxbuy = max(BUY) if maxbuy==0: print(0) else: for i in range(M): if maxbuy==BUY[i]: print(i+1)