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) dct = {} for i in range(m): for j in range(n): if ment[i][0] <= cond[j][0] and ment[i][1] >= cond[j][1]: dct.setdefault(i+1, 0) dct[i+1] += 1 if len(dct) == 0: print(0) else: res = [i for i,j in dct.items() if j == max(dct.values())] for i in res: print(i)