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 i in range(m): for j in range(n): if ment[i][0] <= cond[j][0] and ment[i][1] >= cond[j][1]: cnt[i] += 1 mx = max(cnt) ls = [n for n,i in enumerate(cnt) if i == mx ] if cnt == 0: print(0) else: for i in ls: print(i+1)