N = int(input()) AB = [tuple(map(int,input().split())) for i in range(N)] M = int(input()) XY = [tuple(map(int,input().split())) for i in range(M)] C = [0]*M for a,b in AB : for i, xy in enumerate(XY) : x,y = xy if a >= x and b <= y : C[i] += 1 MAX = max(1,max(C)) for i,c in enumerate(C) : if c == MAX : print(i+1)