import sys input = sys.stdin.readline N = int(input()) A, B = [0] * N, [0] * N for i in range(N): A[i], B[i] = map(int, input().split()) M = int(input()) X, Y = [0] * M, [0] * M for i in range(M): X[i], Y[i] = map(int, input().split()) ma = 1 ans = [] for i in range(M): cnt = 0 for j in range(N): if X[i] <= A[j] and Y[i] >= B[j]: cnt += 1 if cnt > ma: ans = [i + 1] ma = cnt elif cnt == ma: ans.append(i + 1) if ans: for a in ans: print(a) else: print(0)