N, M = map(int, input().split())
windows = []
# 窗口输入时从最下层到最顶层的顺序
for i in range(N):
windows.insert(0, list(map(int, input().split())))
oldwindows = windows[:]
for j in range(M):
flag = False
x, y = map(int, input().split())
for index in range(N):
window = windows[index]
if x >= window[0] and x <= window[2] and y >= window[1] and y <= window[3]:
print(N - oldwindows.index(window))
windows.remove(window)
windows.insert(0, window)
flag = True
break
if flag == False:
print("IGNORED")