let rec seq a b = if a > b then [] else a :: seq (a+1) b
let (>>=) x f = List.map f x |> List.concat
let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun x y z -> x,y,z)) in
  ([-1;1] >>= fun s1 ->
   [-1;1] >>= fun s2 ->
   [-1;1] >>= fun s3 -> [
     let ga = Array.map (fun (x,y,z) -> (s1*x + s2*y + s3*z, (x,y,z))) a in
     Array.sort compare ga;
     let g1,g2,g3 =
       Array.init m (fun i -> snd ga.(i))
       |> Array.fold_left (fun (a,b,c) (x,y,z) -> (a+x,b+y,c+z)) (0,0,0)
     in abs g1 + abs g2 + abs g3
   ])
  |> List.fold_left max (-10101010101010)
  |> Printf.printf "%d\n"