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

let eightval lst = 
  let sgn = [1L;-1L]
  match lst with
    | [x;y;z] -> [ for i in sgn do for j in sgn do for k in sgn do yield i*x + j*y + k*z ]
    | _ -> failwith "omg"

// read N and M
let [|n;m|] = stdin.ReadLine().Split() |> Array.map int
// read Data with int64
let inline scanLongInts _ = stdin.ReadLine().Split() |> Array.map int64 |> Array.toList
let xs = [ for i in 1..n -> scanLongInts 0 ]
// do the work
xs
|> List.map eightval
|> transpose
|> List.map (List.toArray >> Array.sort >> Array.rev >> (fun a -> a.[0..m-1]) >> Array.sum)
|> Seq.max
|> printfn "%d"