n,m=map(int,input().split())
AB=[]
CD=[]
j=1
for i in range(n):
  AB.append([j]+list(map(int,input().split())))
  j+=1
AB.sort(key=lambda x:x[1])
j=1
for i in range(m):
  CD.append([j]+list(map(int,input().split())))
  j+=1
CD.sort(key=lambda x:x[1])

# print(AB)
# print(CD)

inf=float('inf')
ans=[[0,0] for i in range(n)]
for i in range(len(AB)):
  tmp=inf
  for j in range(-1,2):
    if 0<= i+j <=m-1:
      # print("i",i,"j",j)
      if tmp > abs(AB[i][1]-CD[i+j][1])+abs(AB[i][2]-CD[i+j][2]):
        tmp=abs(AB[i][1]-CD[i+j][1])+abs(AB[i][2]-CD[i+j][2])
        ans[i][0],ans[i][1]=AB[i][0],CD[i+j][0]

ans.sort()

for i in ans:
  print(i[1])
