import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=V.mapM_ print.solve.map((\[a,b]->(a,b)).unfoldr(B.readInt.B.dropWhile isSpace)).B.lines=<<B.getContents
solve((n,m):abcd)=V.map f ab where
  (ab,cd)=V.splitAt n$V.fromList abcd
  f(a,b)=snd.V.minimum$V.imap(\i (c,d)->(abs(a-c)+abs(b-d),i+1))cd