let rec transpose = function
    | (_::_)::_ as M -> List.map List.head M :: transpose (List.map List.tail M)
    | _ -> []

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 List.map (fun fn -> fn ar) eightFn ]
// do the work
processedInput
|> transpose
|> List.map (List.toArray >> Array.sort >> Array.rev >> (fun a -> a.[0..m-1]) >> Array.sum)
|> Seq.max
|> printfn "%d"