#yuki647 n=int(raw_input()) ab=[map(int,raw_input().split()) for i in xrange(n)] m=int(raw_input()) xy=[map(int,raw_input().split()) for i in xrange(m)] cnt=[0 for i in xrange(m)] for i in xrange(m): for j in xrange(n): if xy[i][0]<=ab[j][0] and xy[i][1]>=ab[j][1]: cnt[i]+=1 res=[] for i in xrange(m): if cnt[i]==max(cnt): res.append(i+1) if cnt==[0]: print 0 else: for i in xrange(len(res)): print res[i]