from collections import defaultdict N = int(input()) rec = [] for i in range(N): a, b = map(int, input().split()) rec.append((a, b)) M = int(input()) max_ = 0 dic = defaultdict(int) tmp = [] for i in range(M): x, y = map(int, input().split()) for s in rec: if s[0] >= x and s[1] <= y: dic[i] += 1 if dic[i] == max_: tmp.append(i) if dic[i] > max_: max_ = dic[i] tmp = [i] if len(tmp) == 0: print(0) else: for i in tmp: print(i + 1)