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

from itertools import product

import numpy as np

def inpl(): return list(map(int, input().split()))



N, M = inpl()



X, Y, Z = [], [], []



for _ in range(N):

    x, y, z = inpl()

    X.append(x)

    Y.append(y)

    Z.append(z)



X = np.array(X, dtype=np.int64)

Y = np.array(Y, dtype=np.int64)

Z = np.array(Z, dtype=np.int64)





ans = 0

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

    S = (a*X + b*Y + c*Z)

    S.sort()

    ans = max(ans, abs(np.sum(S[:M])))



print(ans)
# -*- coding: utf-8 -*-

from itertools import product

import numpy as np

def inpl():return list(map(int,input().split()))

N,M=inpl()

A,a=np.zeros((N,3),dtype=np.int64),0

for i in range(N):A[i]=np.array(inpl())

for X in product([1,-1],repeat=3):a=max(a,abs(sum(sorted((A*np.array(X)).sum(axis=1))[:M])))

print(a)
# -*- coding: utf-8 -*-
from itertools import product
import numpy as np


def inpl():
    return list(map(int, input().split()))


N, M = inpl()
X, Y, Z = [], [], []
for _ in range(N):
    x, y, z = inpl()
    X.append(x)
    Y.append(y)
    Z.append(z)
X = np.array(X, dtype=np.int64)
Y = np.array(Y, dtype=np.int64)
Z = np.array(Z, dtype=np.int64)
ans = 0
for a, b, c in product([1, -1], repeat=3):
    S = a * X + b * Y + c * Z
    S.sort()
    ans = max(ans, abs(np.sum(S[:M])))
print(ans)

# -*- coding: utf-8 -*-
from itertools import product
import numpy as np


def inpl():
    return list(map(int, input().split()))


N, M = inpl()
A, a = np.zeros((N, 3), dtype=np.int64), 0
for i in range(N):
    A[i] = np.array(inpl())
for X in product([1, -1], repeat=3):
    a = max(a, abs(sum(sorted((A * np.array(X)).sum(axis=1))[:M])))
print(a)

-X, Y, Z = [], [], [] -for _ in range(N): -    x, y, z = inpl() -    X.append(x) -    Y.append(y) -    Z.append(z) -X = np.array(X, dtype=np.int64) -Y = np.array(Y, dtype=np.int64) -Z = np.array(Z, dtype=np.int64) -ans = 0 -for a, b, c in product([1, -1], repeat=3): -    S = a * X + b * Y + c * Z -    S.sort() -    ans = max(ans, abs(np.sum(S[:M]))) -print(ans) +A, a = np.zeros((N, 3), dtype=np.int64), 0 +for i in range(N): +    A[i] = np.array(inpl()) +for X in product([1, -1], repeat=3): +    a = max(a, abs(sum(sorted((A * np.array(X)).sum(axis=1))[:M]))) +print(a)