import sys input = sys.stdin.readline N=int(input()) P=[list(map(int,input().split())) for i in range(N)] M=int(input()) Q=[list(map(int,input().split())) for i in range(M)] ANS=[0]*M for i in range(M): x,y=Q[i] for z,w in P: if x<=z and y>=w: ANS[i]+=1 MAX=max(ANS) if MAX==0: print(0) else: for i in range(M): if MAX==ANS[i]: print(i+1)