n=int(input()) ab=[list(map(int,input().split())) for i in'.'*n] m=int(input()) xy=[list(map(int,input().split())) for i in'.'*m] d=[] for i in xy: c=0 for j in ab: c+=((i[0]<=j[0] and i[1]>=j[1])) d+=[c] for i in range(m): if max(d)==0: print(0) break if d[i]==max(d): print(i+1)