N=int(input()) A=[] B=[] for i in range(N): a,b=map(int,input().split()) A.append(a) B.append(b) M=int(input()) ans=[0 for i in range(M+1)] for j in range(M): X,Y=map(int,input().split()) for k in range(N): if X<=A[k] and Y>=B[k]: ans[j+1]+=1 m=ans.count(max(ans)) if max(ans)==0: print(0) else: for l in range(M+1): if ans[l]==max(ans) : print(l)