# https://abc100.contest.atcoder.jp/tasks/abc100_d

# D - Patisserie ABC



# D_Patisserie_ABC.py



import collections



N, M = list(map(int, input().strip().split(" ")))

A = [[] for i in range(8)]

for n in range(N):

    # 「綺麗さ」「おいしさ」「人気度」

    x, y, z = list(map(int, input().strip().split(" ")))



    A[0].append(x+y+z)

    A[1].append(-x+y+z)

    A[2].append(x-y+z)

    A[3].append(x+y-z)

    A[4].append(x-y-z)

    A[5].append(-x+y-z)

    A[6].append(-x-y+z)

    A[7].append(-x-y-z)





T = []

for i in range(8):

    A[i].sort()

    total = 0

    for _ in range(M):

        total += A[i].pop()

    T.append(total)



T.sort()

print((T[-1]))

# https://abc100.contest.atcoder.jp/tasks/abc100_d

# D - Patisserie ABC



# D_Patisserie_ABC.py



#import collections



N, M = list(map(int, input().strip().split(" ")))

A = [[] for i in range(8)]

for n in range(N):

    # 「綺麗さ」「おいしさ」「人気度」

    x, y, z = list(map(int, input().strip().split(" ")))



    A[0].append(x+y+z)

    A[1].append(-x+y+z)

    A[2].append(x-y+z)

    A[3].append(x+y-z)

    A[4].append(x-y-z)

    A[5].append(-x+y-z)

    A[6].append(-x-y+z)

    A[7].append(-x-y-z)





T = []

for i in range(8):

    A[i].sort()

    total = 0

    for _ in range(M):

        total += A[i].pop()

    T.append(total)



T.sort()

print((T[-1]))

# https://abc100.contest.atcoder.jp/tasks/abc100_d
# D - Patisserie ABC
# D_Patisserie_ABC.py
import collections

N, M = list(map(int, input().strip().split(" ")))
A = [[] for i in range(8)]
for n in range(N):
    # 「綺麗さ」「おいしさ」「人気度」
    x, y, z = list(map(int, input().strip().split(" ")))
    A[0].append(x + y + z)
    A[1].append(-x + y + z)
    A[2].append(x - y + z)
    A[3].append(x + y - z)
    A[4].append(x - y - z)
    A[5].append(-x + y - z)
    A[6].append(-x - y + z)
    A[7].append(-x - y - z)
T = []
for i in range(8):
    A[i].sort()
    total = 0
    for _ in range(M):
        total += A[i].pop()
    T.append(total)
T.sort()
print((T[-1]))

# https://abc100.contest.atcoder.jp/tasks/abc100_d
# D - Patisserie ABC
# D_Patisserie_ABC.py
# import collections
N, M = list(map(int, input().strip().split(" ")))
A = [[] for i in range(8)]
for n in range(N):
    # 「綺麗さ」「おいしさ」「人気度」
    x, y, z = list(map(int, input().strip().split(" ")))
    A[0].append(x + y + z)
    A[1].append(-x + y + z)
    A[2].append(x - y + z)
    A[3].append(x + y - z)
    A[4].append(x - y - z)
    A[5].append(-x + y - z)
    A[6].append(-x - y + z)
    A[7].append(-x - y - z)
T = []
for i in range(8):
    A[i].sort()
    total = 0
    for _ in range(M):
        total += A[i].pop()
    T.append(total)
T.sort()
print((T[-1]))

-import collections - +# import collections