using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.CakeCount = inpt[0];
        this.MaxEat = inpt[1];
        this.Cakes = new long[this.CakeCount][];

        this.dic = new long[this.CakeCount][][][];
        for (int i = 0; i < this.CakeCount; i++)
        {
            this.Cakes[i] = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        }

        long ans = 0;
        for (int i = 0; i <= 7; i++)
        {
            long[] tmp = GetAns(0, this.MaxEat, i);
            ans = Math.Max(ans, tmp.Select(a => Math.Abs(a)).Sum());
        }
        Console.WriteLine(ans);
    }

    private int CakeCount;
    private int MaxEat;

    private long[][] Cakes;

    private long[] GetAns(int idx, int remain, int type)
    {

        if (idx >= this.CakeCount && remain > 0)
        {
            return new long[0];
        }

        if (remain <= 0)
        {
            return new long[3];
        }

        if (dic[idx] == null)
        {
            dic[idx] = new long[this.MaxEat + 1][][];
        }
        if (dic[idx][remain] == null)
        {
            dic[idx][remain] = new long[8][];
        }
        if (dic[idx][remain][type] != null)
        {
            return dic[idx][remain][type];
        }

        long[] tmp1 = GetAns(idx + 1, remain - 1, type);
        if (tmp1.Length == 0)
        {
            dic[idx][remain][type] = tmp1;
            return tmp1;
        }
        tmp1 = (long[])tmp1.Clone();
        for (int i = 0; i < 3; i++)
        {
            tmp1[i] += this.Cakes[idx][i];
        }

        long[] tmp2 = GetAns(idx + 1, remain, type);
        if (tmp2.Length > 0)
        {
            long total1 = 0;
            long total2 = 0;

            for (int i = 0; i < tmp1.Length; i++)
            {
                if ((type & TypeArr[i]) == 0)
                {
                    total1 += tmp1[i];
                    total2 += tmp2[i];
                }
                else
                {
                    total1 -= tmp1[i];
                    total2 -= tmp2[i];
                }
            }
            if (total1 >= total2)
            {
                dic[idx][remain][type] = tmp1;
                return tmp1;
            }
            else
            {
                dic[idx][remain][type] = tmp2;
                return tmp2;
            }
        }
        else
        {
            dic[idx][remain][type] = tmp1;
            return tmp1;
        }

    }
    private int[] TypeArr = new int[] { 1, 2, 4 };

    private long[][][][] dic;

    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"
 
 
 
3 0
2000000000 -9000000000 4000000000
7000000000 -5000000000 3000000000
6000000000 -1000000000 8000000000 
 
 
";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 150912