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

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

ans=0

for i in range(8):

    i=bin(i)[2:].zfill(3)

    k=[]

    for j in range(3):

        if i[j]=="0":

            k.append(1)

        else:

            k.append(-1)

    l=[k[0]*x+k[1]*y+k[2]*z for x,y,z in xyz]

    l.sort(reverse=True)

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

print(ans)

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

xyz=[]

for i in range(N):

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

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

ans=0

for k in range(8):

    A=[k>>2 &1,k>>1 &1,k>>0 &1]

    l=[]

    for i in range(N):

        t=0

        for j in range(3):

            if A[j]==0:

                t+=xyz[i][j]

            else:

                t-=xyz[i][j]

        l.append(t)

    l.sort(reverse=True)

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

print(ans)

N, M = list(map(int, input().split()))
xyz = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(8):
    i = bin(i)[2:].zfill(3)
    k = []
    for j in range(3):
        if i[j] == "0":
            k.append(1)
        else:
            k.append(-1)
    l = [k[0] * x + k[1] * y + k[2] * z for x, y, z in xyz]
    l.sort(reverse=True)
    ans = max(ans, sum(l[:M]))
print(ans)

N, M = list(map(int, input().split()))
xyz = []
for i in range(N):
    x, y, z = list(map(int, input().split()))
    xyz.append([x, y, z])
ans = 0
for k in range(8):
    A = [k >> 2 & 1, k >> 1 & 1, k >> 0 & 1]
    l = []
    for i in range(N):
        t = 0
        for j in range(3):
            if A[j] == 0:
                t += xyz[i][j]
            else:
                t -= xyz[i][j]
        l.append(t)
    l.sort(reverse=True)
    ans = max(ans, sum(l[:M]))
print(ans)

-xyz = [list(map(int, input().split())) for i in range(N)] +xyz = [] +for i in range(N): +    x, y, z = list(map(int, input().split())) +    xyz.append([x, y, z]) -for i in range(8): -    i = bin(i)[2:].zfill(3) -    k = [] -    for j in range(3): -        if i[j] == "0": -            k.append(1) -        else: -            k.append(-1) -    l = [k[0] * x + k[1] * y + k[2] * z for x, y, z in xyz] +for k in range(8): +    A = [k >> 2 & 1, k >> 1 & 1, k >> 0 & 1] +    l = [] +    for i in range(N): +        t = 0 +        for j in range(3): +            if A[j] == 0: +                t += xyz[i][j] +            else: +                t -= xyz[i][j] +        l.append(t)