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

main = do
  (n:m:_) <- (map read) . words <$> getLine
  stud <- replicateM n ((map read) . words <$> getLine)
  check <- replicateM m ((map read) . words <$> getLine)

  mapM_ print $ mapMaybe (\(a:b:_) -> f (map (\(c:d:_) -> abs(a-c)+abs(b-d)) check)) stud

  where
    f :: [Int] -> Maybe Int
    f xs = fmap (+1) (elemIndex min xs)
      where
        min = minimum xs
