n=int(input()) l=[list(map(int,input().split())) for i in range(n)] m=int(input()) c=[0]*m for i in range(m): p,s=map(int,input().split()) t=0 for j in range(n): if p<=l[j][0] and s>=l[j][1]: t+=1 c[i]=t if sum(c)==0: print(0) else: for i in range(m): if c[i]==max(c): print(i+1)