import collections a=int(input()) b=[] for i in range(a): b.append([int(i) for i in input().split()]) c=int(input()) d=[] for i in range(c): d.append([int(i) for i in input().split()]) e=[] for i in b: for m,j in enumerate(d): if (i[0]>=j[0]) and (i[1]<=j[1]): e.append(m+1) z=collections.Counter(e) if len(z)==0: print(0) else: for i in z: if max(z)==z[i]: print(i)