// eight possible abs handling patterns
let eightFn = 
    [| for i in [1L;-1L] do 
       for j in [1L;-1L] do 
       for k in [1L;-1L] do 
            yield (fun (ar: int64[]) -> i*ar.[0] + j*ar.[1] + k*ar.[2]) |]
// read N and M
let [|n;m|] = stdin.ReadLine().Split() |> Array.map int
// generate processed input, using int64.
let processedInput =
    [| for i in 1..n do
         let ar = stdin.ReadLine().Split() |> Array.map int64
         yield Array.map (fun fn -> fn ar) eightFn |]
// do the work
[ for i in 0..7 do
    let arr = Array.map (fun (ar: int64[]) -> ar.[i]) processedInput
    Array.sortInPlace arr // mutate!
    yield (Array.sum arr.[n-m..n-1]) ]
|> List.max
|> printfn "%d"