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

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

ans = [[] for _ in range(8)]

for x,y,z in xyz:

    for i in range(8):

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

out = []

for i in range(8):

    ans[i].sort(reverse=True)

    out.append(sum(ans[i][:M]))

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

XYZ = [list(map(int,input().split())) for _ in [0]*N]

W = [[0]*N for _ in [0]*4]

for i,xyz in enumerate(XYZ):

    x,y,z = xyz

    W[0][i] = x+y+z

    W[1][i] = x+y-z

    W[2][i] = x-y+z

    W[3][i] = x-y-z

ans = 0

for i in range(4):

    W[i].sort()

    ans = max(ans,

             abs(sum(W[i][:M])),

             abs(sum(W[i][-M:])))

if M==0:ans=0

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

N, M = list(map(int, input().split()))
XYZ = [list(map(int, input().split())) for _ in [0] * N]
W = [[0] * N for _ in [0] * 4]
for i, xyz in enumerate(XYZ):
    x, y, z = xyz
    W[0][i] = x + y + z
    W[1][i] = x + y - z
    W[2][i] = x - y + z
    W[3][i] = x - y - z
ans = 0
for i in range(4):
    W[i].sort()
    ans = max(ans, abs(sum(W[i][:M])), abs(sum(W[i][-M:])))
if M == 0:
    ans = 0
print(ans)

-xyz = [list(map(int, input().split())) for _ in range(N)] -ans = [[] for _ in range(8)] -for x, y, z in xyz: -    for i in range(8): -        ans[i].append(x * ((-1) ** i) + y * ((-1) ** (i // 2)) + z * ((-1) ** (i // 4))) -out = [] -for i in range(8): -    ans[i].sort(reverse=True) -    out.append(sum(ans[i][:M])) -print((max(out))) +XYZ = [list(map(int, input().split())) for _ in [0] * N] +W = [[0] * N for _ in [0] * 4] +for i, xyz in enumerate(XYZ): +    x, y, z = xyz +    W[0][i] = x + y + z +    W[1][i] = x + y - z +    W[2][i] = x - y + z +    W[3][i] = x - y - z +ans = 0 +for i in range(4): +    W[i].sort() +    ans = max(ans, abs(sum(W[i][:M])), abs(sum(W[i][-M:]))) +if M == 0: +    ans = 0 +print(ans)