def is_buy(budget,taste): def _(price,hot): return budget >= price and taste <= hot return _ N = int(input()) members = [is_buy(*map(int,input().split())) for x in range(N)] M = int(input()) mentaiko = {} popular = 0 for i in range(M): price,hot = map(int,input().split()) cnt = 0 for member in members: if member(price,hot): cnt+=1 if cnt: mentaiko[i + 1] = cnt popular = max(popular,cnt) if mentaiko: mentaiko = sorted([x for x,y in mentaiko.items() if y == popular]) for miracle in mentaiko: print(miracle) else: print(0)