n = int(input()) cond = [] for i in range(n): inp = list(map(int,input().split())) cond.append(inp) m = int(input()) ment = [] for i in range(m): inp = list(map(int,input().split())) ment.append(inp) cnt = [0 for i in range(m)] for l,i in enumerate(ment): for j in cond: if i[0] <= j[0] and i[1] >= j[1]: cnt[l] += 1 mx = max(cnt) if mx == 0: print(0) else: for i,j in enumerate(cnt): if j == mx: print(i+1)