N = int(input()) member = [] for _ in range(N): a,b = map(int,input().split()) member.append((a,b)) M = int(input()) dat = [0] * M m = -1 for _ in range(M): x,y = map(int,input().split()) count = 0 for a,b in member: if x <= a and y >= b: count += 1 dat[_] = count if count > m:m = count import sys if m == 0: print(0) exit() for i in range(M): if dat[i] == m: print(i + 1)