import Control.Monad
import Data.List
import Data.Int

main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  [x, y, z] <- transpose <$> replicateM n (map read . words <$> getLine) :: IO [[Int64]]
  print $ solve x y z m

inf :: Int64
inf = -10^18

solve :: [Int64] -> [Int64] -> [Int64] -> Int -> Int64
solve a b c m = maximum [maxsum (map (*i) a) (map (*j) b) (map (*k) c) m | i <- [-1, 1], j <- [-1, 1], k <- [-1, 1]]

maxsum :: [Int64] -> [Int64] -> [Int64] -> Int -> Int64
maxsum a b c m = sum . take m . reverse . sort . map (\(x, y, z) -> x + y + z) $ zip3 a b c


