import Data.List

distance::(Int,Int)->(Int,Int)-> Int
distance (x,y)(a,b)= (abs (x-a))+(abs (y-b))

ord::(Int,Int)->(Int,Int)->Ordering
ord (_,x)(_,y) = if x == y then  EQ else if x <= y then LT else GT

one_solver::(Int,Int)->[(Int,(Int,Int))]->Int
one_solver x chs = let id_dist = map (\(i,c)->(i,distance x c)) chs in
                   let (this,_) = head (sortBy ord id_dist) in
                   this

solver::[(Int,Int)]->[(Int,Int)]->[Int]
solver stu chs = let id_with = zip [1..] chs in
                 map (\x -> one_solver x id_with) stu

printer::[Int]->IO()
printer []= return ()
printer (x:xs)= do
  print x
  printer xs

getter::Int->IO([(Int,Int)])
getter 0 = return []
getter n = do
  xyc<-getLine
  let x:y:[]=map read (words xyc)
  rest<-getter (n-1)
  return ((x,y):rest)

main::IO()
main=do
  nmc<-getLine
  let n:m:[]= map read (words nmc)
  stu<-getter n
  chs<-getter m
  printer (solver stu chs)