n=int(input()) p=[tuple(map(int,input().split())) for i in range(n)] m=int(input()) q=[tuple(map(int,input().split())) for i in range(m)] c=[0]*m for i in range(m): x,y=q[i] for j in range(n): a,b=p[j] c[i]+=x<=a and y>=b C=max(c) if C==0: print(0) exit() for i in range(m): if c[i]==C: print(i+1)