function Main(input) {
    var col = input.split('\n');
    var row;
    var M;
    var xyz = [];
    
    for (var i = 0 ; i < col.length ; ++i) {
        row = col[i].split(' ');
        
        if (i === 0) {
            M = Number(row[1]);
        } else {
            xyz.push([Number(row[0]), Number(row[1]), Number(row[2])]);   
        }
    }

    var res = [[], [], [], [], [], [], [], []];

    for (var i = 0 ; i < xyz.length ; ++i) {
        res[0].push(+xyz[i][0] + xyz[i][1] + xyz[i][2]);
        res[1].push(-xyz[i][0] + xyz[i][1] + xyz[i][2]);
        res[2].push(+xyz[i][0] - xyz[i][1] + xyz[i][2]);
        res[3].push(+xyz[i][0] + xyz[i][1] - xyz[i][2]);
        res[4].push(-xyz[i][0] - xyz[i][1] + xyz[i][2]);
        res[5].push(+xyz[i][0] - xyz[i][1] - xyz[i][2]);
        res[6].push(-xyz[i][0] + xyz[i][1] - xyz[i][2]);
        res[7].push(-xyz[i][0] - xyz[i][1] - xyz[i][2]);
    }

    for (var i = 0 ; i < res.length ; ++i) res[i].sort((a, b) => a < b);
    
    var result = null;
    for (var i = 0 ; i < res.length ; ++i) {
        var s = 0;
        for (var j = 0 ; j < M ; ++j) s += res[i][j];
        if (result === null || result < s) {
            result = s;
        }
    }
    console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
