class ClubMember: def __init__(self,budget,hot): self.budget = budget self.hot = hot self.buy = [] def choice(self,number,price,hot): if price <= self.budget and hot >= self.hot: self.buy.append(number) def show(self): return self.buy N = int(input()) members = [ClubMember(*map(int,input().split())) for x in range(N)] M = int(input()) for i in range(M): price,hot = map(int,input().split()) for member in members: member.choice(i + 1,price,hot) members = [y for x in members if x.show() for y in x.show()] if members: mentaiko = {} for i in members: mentaiko.setdefault(i,0) mentaiko[i]+=1 miracle = max(mentaiko.values()) miracle = [x for x,y in mentaiko.items() if y == miracle] miracle.sort() for i in miracle: print(i) else: print(0)