member = [] menta = [] # 10^4 n = int(input()) for _ in range(n): member.append(list(map(int, input().split()))) # 10^3 m = int(input()) for _ in range(m): menta.append(list(map(int, input().split()))) # print(member) # print(menta) # 10^3 * 10^4 numOfBuy = [] for index, (x, y) in enumerate(menta): # print('menta ', index, x, y) current = 0 for a, b in member: # print(f'member (yen, spice) = ({a}, {b})') if x <= a and b <= y: current += 1 if current != 0: numOfBuy.append(current) # print(f'{index} : menta = {current}') # print(numOfBuy) if not numOfBuy: print(0) else: max = max(numOfBuy) for idx, num in enumerate(numOfBuy): if num == max: print(idx + 1)