# -*- coding: utf-8 -*-

# AtCoder Beginner Contest





if __name__ == '__main__':

    from itertools import product

    from heapq import nlargest



    n, m = list(map(int, input().split()))

    xyz = [list(map(int, input().split())) for i in range(n)]

    ans = 0



    # See:

    # https://beta.atcoder.jp/contests/abc100/submissions/2691346

    for a, b, c in product((-1, 1), repeat=3):

        summed_xyz = [0 for _ in range(n)]

        i = 0



        for x, y, z in xyz:

            summed_xyz[i] = (x * a) + (y * b) + (z * c)

            i += 1



        ans = max(ans, sum(nlargest(m, summed_xyz)))



    print(ans)

# -*- coding: utf-8 -*-





def main():

    from itertools import product



    n, m = list(map(int, input().split()))

    xyz = [list(map(int, input().split())) for _ in range(n)]

    ans = 0



    for op1, op2, op3 in list(product([1, -1], repeat=3)):

        tmp = [[0, 0, 0]] * n



        for index, value in enumerate(xyz):

            tmp[index] = sum([op1 * value[0], op2 * value[1], op3 * value[2]])



        camdidates = sorted(tmp, reverse=True)

        ans = max(ans, sum(camdidates[:m]))



    print(ans)





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
if __name__ == "__main__":
    from itertools import product
    from heapq import nlargest

    n, m = list(map(int, input().split()))
    xyz = [list(map(int, input().split())) for i in range(n)]
    ans = 0
    # See:
    # https://beta.atcoder.jp/contests/abc100/submissions/2691346
    for a, b, c in product((-1, 1), repeat=3):
        summed_xyz = [0 for _ in range(n)]
        i = 0
        for x, y, z in xyz:
            summed_xyz[i] = (x * a) + (y * b) + (z * c)
            i += 1
        ans = max(ans, sum(nlargest(m, summed_xyz)))
    print(ans)

# -*- coding: utf-8 -*-
def main():
    from itertools import product

    n, m = list(map(int, input().split()))
    xyz = [list(map(int, input().split())) for _ in range(n)]
    ans = 0
    for op1, op2, op3 in list(product([1, -1], repeat=3)):
        tmp = [[0, 0, 0]] * n
        for index, value in enumerate(xyz):
            tmp[index] = sum([op1 * value[0], op2 * value[1], op3 * value[2]])
        camdidates = sorted(tmp, reverse=True)
        ans = max(ans, sum(camdidates[:m]))
    print(ans)


if __name__ == "__main__":
    main()

-# AtCoder Beginner Contest -if __name__ == "__main__": +def main(): -    from heapq import nlargest -    xyz = [list(map(int, input().split())) for i in range(n)] +    xyz = [list(map(int, input().split())) for _ in range(n)] -    # See: -    # https://beta.atcoder.jp/contests/abc100/submissions/2691346 -    for a, b, c in product((-1, 1), repeat=3): -        summed_xyz = [0 for _ in range(n)] -        i = 0 -        for x, y, z in xyz: -            summed_xyz[i] = (x * a) + (y * b) + (z * c) -            i += 1 -        ans = max(ans, sum(nlargest(m, summed_xyz))) +    for op1, op2, op3 in list(product([1, -1], repeat=3)): +        tmp = [[0, 0, 0]] * n +        for index, value in enumerate(xyz): +            tmp[index] = sum([op1 * value[0], op2 * value[1], op3 * value[2]]) +        camdidates = sorted(tmp, reverse=True) +        ans = max(ans, sum(camdidates[:m])) + + +if __name__ == "__main__": +    main()