import Data.List
import Control.Monad

solve :: Int -> Int -> [[Int]] -> Int
solve n m xyz = maximum . map f $ replicateM 3 [-1,1] where
  f p = sum' . take m . sortBy (flip compare) $
        map (sum . zipWith (*) p) xyz

sum' = sum . (0:)

main = do
  [n, m] <- readWords
  xyz <- replicateM n readWords
  print $ solve n m xyz

readWords = map read . words <$> getLine
