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

A = [[int(i) for i in input().split()] for i in range(N)]



ans = 0

for i in range(1 << 3):

    x = bin(i)[2:]

    while len(x) < 3:

        x = '0' + x

    op = ''

    for j in x:

        if j == '1':

            op += '+'

        else:

            op += '-'

    B = []

    for j in range(N):

        B.append(eval(op[0] + str(A[j][0]) + op[1] + str(A[j][1]) + op[2] + str(A[j][2])))

    B.sort(reverse = True)

    ans = max(ans, sum(B[:M]))

    

print(ans)
N, M = list(map(int, input().split()))

A = [[int(i) for i in input().split()] for i in range(N)]



def f(x):

    if x == 1:

        return 1

    else:

        return -1



ans = 0

for i in range(1 << 3):

    B = []

    for x, y, z in A:

        B.append(f((i >> 2) & 1) * x + f((i >> 1) & 1) * y + f(i & 1) * z)

    B.sort(reverse = True)

    ans = max(ans, sum(B[:M]))

    

print(ans)
N, M = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(N)]
ans = 0
for i in range(1 << 3):
    x = bin(i)[2:]
    while len(x) < 3:
        x = "0" + x
    op = ""
    for j in x:
        if j == "1":
            op += "+"
        else:
            op += "-"
    B = []
    for j in range(N):
        B.append(
            eval(op[0] + str(A[j][0]) + op[1] + str(A[j][1]) + op[2] + str(A[j][2]))
        )
    B.sort(reverse=True)
    ans = max(ans, sum(B[:M]))
print(ans)

N, M = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(N)]


def f(x):
    if x == 1:
        return 1
    else:
        return -1


ans = 0
for i in range(1 << 3):
    B = []
    for x, y, z in A:
        B.append(f((i >> 2) & 1) * x + f((i >> 1) & 1) * y + f(i & 1) * z)
    B.sort(reverse=True)
    ans = max(ans, sum(B[:M]))
print(ans)

+ + +def f(x): +    if x == 1: +        return 1 +    else: +        return -1 + + -    x = bin(i)[2:] -    while len(x) < 3: -        x = "0" + x -    op = "" -    for j in x: -        if j == "1": -            op += "+" -        else: -            op += "-" -    for j in range(N): -        B.append( -            eval(op[0] + str(A[j][0]) + op[1] + str(A[j][1]) + op[2] + str(A[j][2])) -        ) +    for x, y, z in A: +        B.append(f((i >> 2) & 1) * x + f((i >> 1) & 1) * y + f(i & 1) * z)