import Control.Applicative
import Control.Monad
import Data.List

trans :: [String] -> [[Integer]] 
trans []=[]
trans (x:xs)=(map read.words$x) : trans xs

dist [a,b] [c,d]=abs (a-c)+abs (b-d)

comp a b=compare (snd a) (snd b)

nearFt :: [[Integer]] -> [Integer] -> Integer
nearFt checkPts student=(fst.head) $ sortBy comp $zip [1,2..] (map (dist student) checkPts)

nearPts :: [[Integer]] -> [[Integer]] -> [Integer]
nearPts students checkPts=map (nearFt checkPts) students

output n students checkPts size_n=do
  if(n==1) then 
             (putStrLn.show) $ last (nearPts students checkPts)
           else do
             (putStrLn.show) $ (nearPts students checkPts)!!(size_n-n)
             output (n-1) students checkPts size_n

main=do
  [n,m]<-map read.words<$>getLine
  data_students<- replicateM n getLine
  data_checkPts<- replicateM m getLine
  output n (trans data_students) (trans data_checkPts) n