member = [] for _ in range(int(input())): a, b = map(int, input().split()) member.append([a, b]) item = [] for _ in range(int(input())): a, b = map(int, input().split()) item.append([a, b, 0]) for [a, b] in member: for i in range(len(item)): x, y, z = item[i] if a >= x and b <= y: item[i] = [x, y, 1] count = 0 for i in range(len(item)): x, y, z = item[i] if z == 1: print(i + 1)