N=int(input()) listn=[] listm=[] for i in range(N): a,b=map(int,input().split()) listn.append([a,b]) M=int(input()) for j in range(M): a,b=map(int,input().split()) listm.append([a,b]) #print(listn) #print(listm) listM=[] for k in range(M): listM.append([0,k]) for l in range(N): for m in range(M): if listn[l][0]>=listm[m][0] and listn[l][1]<=listm[m][1]: listM[m][0]+=1 if listM[0][0]==0: print(0) else: listM.sort(reverse=True) listANS=[listM[0][1]] for n in range(1,M): if listM[n][0]==listM[0][0]: listANS.append(listM[n][1]) else: break listANS.sort() for o in range(len(listANS)): print(listANS[o]+1) #print(listM)