n = int(input()) pab = [list(map(int, input().split())) for i in range(n)] m = int(input()) pxy = [list(map(int, input().split())) for i in range(m)] pc = [0 for i in range(m)] for j in range(m): for a,b in pab: if a >= pxy[j][0] and b <= pxy[j][1]: pc[j] += 1 cMax = max(pc) if cMax == 0: print(0) else: for i in range(m): if pc[i] == cMax: print(i + 1)