import           Control.Monad

main :: IO ()
main = do
  [n, m] <- readInts
  students <- replicateM n readInts
  checkpoints <- zipWith (:) [1..] <$> replicateM m readInts
  forM_ students $ print . solve checkpoints

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: [[Int]] -> [Int] -> Int
solve checkpoints [a, b]
  = minimum
  $ map head
  $ filter (\[i, dist] -> dist == dist_min) dists
    where
      dists = map (\[i, c, d] -> [i, abs (c - a) + abs (d - b)]) checkpoints
      dist_min = minimum [ dist | [_, dist] <- dists ]