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-b)+abs (c-d)

nearFt :: [[Integer]] -> [Integer] -> Integer
nearFt checkPts student=(fst.head) $ sortBy ordDist $zip [1..] checkPts  
    where ordDist a b=compare (dist (snd a) student) (dist (snd b) student)

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

output n students checkPts=do
  if(n==1) then 
             (putStrLn.show) $ head (nearPts students checkPts)
           else do
             (putStrLn.show) $ take n (nearPts students checkPts)
             output (n-1) students checkPts

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)