import bisect
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
AB = sorted(ab)
for x,y in cd:
    a = bisect.bisect_left(AB, [x,y])
    print(ab.index(AB[a])+1)