import Control.Monad
f c s = foldl1 (g s) c
g s cp cq =if abs(head(snd cq)-head s)+abs(last(snd cq)-last s)<=abs(head(snd cp)-head s)+abs(last(snd cp)-last s) then cq else cp
main=do
 [n,m]<-map read.words<$>getLine
 st<-replicateM n (map read.words<$>getLine)
 ct<-replicateM m (map read.words<$>getLine)
 let c = zip [1..m] ct
 putStrLn$unlines$map show$map fst.(f c) st