# coding: utf-8 # Your code here! n = int(input()) a = [] b = [] for i in range(n): ai,bi=[int(i) for i in input().split()] a.append(ai) b.append(bi) m = int(input()) x = [] y = [] for i in range(m): xi,yi=[int(i) for i in input().split()] x.append(xi) y.append(yi) count = [0] * m for i in range(n): price = a[i] hot = b[i] for j in range(m): if x[j] <= price and y[j] >= hot: count[j] += 1 max_tarako = max(count) if max_tarako != 0: max_index = [i for i, x in enumerate(count) if x == max_tarako] for i in range(len(max_index)): print(max_index[i]+1) else: print(0)