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

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

for i in range(N):

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

    for i in range(8):

        X[i].append(int(2*((i%2)-1/2))*x + int(2*(((i//2)%2)-1/2))*y + int(2*(((i//4)%2)-1/2))*z)

ans=0

for i in range(8):

    X[i].sort()

    X[i]=X[i][::-1]

    ans=max(sum(X[i][:M]),ans)

    

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



X = []



for i in range(N):

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

    X.append([x,y,z])



max_score = 0

for i in range(8):

    a = i%2

    j = i//2

    b = j%2

    k = j//2

    c = k%2

    a,b,c = 2*a-1,2*b-1,2*c-1

    Z = []

    for j in range(N):

        Z.append(a*X[j][0]+b*X[j][1]+c*X[j][2])

    Z.sort(reverse=True)

    max_score = max(sum(Z[:M]),max_score)



print(max_score)
N, M = list(map(int, input().split()))
X = [[] for i in range(8)]
for i in range(N):
    x, y, z = list(map(int, input().split()))
    for i in range(8):
        X[i].append(
            int(2 * ((i % 2) - 1 / 2)) * x
            + int(2 * (((i // 2) % 2) - 1 / 2)) * y
            + int(2 * (((i // 4) % 2) - 1 / 2)) * z
        )
ans = 0
for i in range(8):
    X[i].sort()
    X[i] = X[i][::-1]
    ans = max(sum(X[i][:M]), ans)
print(ans)

N, M = list(map(int, input().split()))
X = []
for i in range(N):
    x, y, z = list(map(int, input().split()))
    X.append([x, y, z])
max_score = 0
for i in range(8):
    a = i % 2
    j = i // 2
    b = j % 2
    k = j // 2
    c = k % 2
    a, b, c = 2 * a - 1, 2 * b - 1, 2 * c - 1
    Z = []
    for j in range(N):
        Z.append(a * X[j][0] + b * X[j][1] + c * X[j][2])
    Z.sort(reverse=True)
    max_score = max(sum(Z[:M]), max_score)
print(max_score)

-X = [[] for i in range(8)] +X = [] -    for i in range(8): -        X[i].append( -            int(2 * ((i % 2) - 1 / 2)) * x -            + int(2 * (((i // 2) % 2) - 1 / 2)) * y -            + int(2 * (((i // 4) % 2) - 1 / 2)) * z -        ) -ans = 0 +    X.append([x, y, z]) +max_score = 0 -    X[i].sort() -    X[i] = X[i][::-1] -    ans = max(sum(X[i][:M]), ans) -print(ans) +    a = i % 2 +    j = i // 2 +    b = j % 2 +    k = j // 2 +    c = k % 2 +    a, b, c = 2 * a - 1, 2 * b - 1, 2 * c - 1 +    Z = [] +    for j in range(N): +        Z.append(a * X[j][0] + b * X[j][1] + c * X[j][2]) +    Z.sort(reverse=True) +    max_score = max(sum(Z[:M]), max_score) +print(max_score)