import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import std.range;
import std.math;

void main(string[] args) {
  auto input = readln().chomp.split.map!(to!int);

  long[8][1000] score;

  for(int i; i < input[0]; i++){
    auto cake = readln().chomp.split.map!(to!long);
    score[0][i] =  cake[0]+cake[1]+cake[2];
    score[1][i] =  cake[0]+cake[1]-cake[2];
    score[2][i] =  cake[0]-cake[1]+cake[2];
    score[3][i] =  cake[0]-cake[1]-cake[2];
    score[4][i] = -cake[0]+cake[1]+cake[2];
    score[5][i] = -cake[0]+cake[1]-cake[2];
    score[6][i] = -cake[0]-cake[1]+cake[2];
    score[7][i] = -cake[0]-cake[1]-cake[2];
  }

  long[8] result;

  for(int i; i<8; i++){
    auto x = score[i].dup;
    x.sort!"a>b";
    result[i] = x.take(input[1]).sum;
  }

  result.reduce!max.writeln();
}