n = int(input()) nl = [list(map(int, input().split())) for _ in range(n)] m = int(input()) ml = [list(map(int, input().split())) for _ in range(m)] ml2 = [] for i in range(len(ml)): ml2.append([i+1, ml[i][0], ml[i][1]]) l = [] for i, x, y in ml2: for a, b in nl: if x <= a and y >= b: l.append(i) if len(l) == 0: print(0) else: c = {} for i in l: if not i in c: c[i] = 1 else: c[i] += 1 x = max(c.values()) l = [] for i in c: if c[i] == x: print(i)