n = int(input()) a = [list(map(int, input().split())) for i in range(n)] m = int(input()) b = [list(map(int, input().split())) for i in range(m)] l = [0]*(10**3+10) for i in a: for j in range(m): if i[0] >= b[j][0] and i[1] <= b[j][1]: l[j+1] += 1 temp = max(l) if temp == 0: print(temp) else: for i in range(len(l)): if l[i] == temp: print(i)