N = int(input()) Lh = [list(map(int, input().split())) for _ in range(N)] M = int(input()) Lm = [list(map(int, input().split())) + [i+1] for i in range(M)] L = [0] * (M+1) for a, b in Lh: for c, d, i in Lm: if a >= c and b <= d: L[i] += 1 X = max(L) if X == 0: print(0) else: if L.count(X) == 1: print(L.index(X)) else: for i in range(M+1): if X == L[i]: print(i)