import Control.Arrow
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  [n, m] <- getInts
  [xs, ys, zs] <- transpose <$> replicateM n getInts
  print . maximum $ do
    f <- [negate, id]
    g <- [negate, id]
    h <- [negate, id]
    return . sum . take m . reverse . sort . map sum . transpose $ [map f xs, map g ys, map h zs]

getInts :: IO [Int]
getInts = unfoldr (BC.readInt . BC.dropWhile (== ' ')) <$> BC.getLine
