n, m = list(map(int, input().split()))



x = []

y = []

z = []



for i in range(n):

    X, Y, Z = list(map(int, input().split()))

    x.append(X)

    y.append(Y)

    z.append(Z)



sign = [1, -1]



ans = []



for j in sign:

    for k in sign:

        for l in sign:

            a = []

            for i in range(n):

                a.append(x[i] * j + y[i] * k + z[i] * l)

            a.sort(reverse=True)

            ans.append(sum(a[:m]))

print((max(ans)))

n, m = list(map(int, input().split()))



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



box = [[[[] for i in range(2)] for j in range(2)] for k in range(2)]

ans = 0

for i in range(2):

    for j in range(2):

        for k in range(2):

            worth = 0

            for x, y, z in cake:

                if i == 1:

                    x = -x

                if j == 1:

                    y = -y

                if k == 1:

                    z = -z

                box[i][j][k].append(x+y+z)

            box[i][j][k].sort(reverse=True)

            ans = max(ans, sum(box[i][j][k][:m]))



print(ans)
n, m = list(map(int, input().split()))
x = []
y = []
z = []
for i in range(n):
    X, Y, Z = list(map(int, input().split()))
    x.append(X)
    y.append(Y)
    z.append(Z)
sign = [1, -1]
ans = []
for j in sign:
    for k in sign:
        for l in sign:
            a = []
            for i in range(n):
                a.append(x[i] * j + y[i] * k + z[i] * l)
            a.sort(reverse=True)
            ans.append(sum(a[:m]))
print((max(ans)))

n, m = list(map(int, input().split()))
cake = [list(map(int, input().split())) for i in range(n)]
box = [[[[] for i in range(2)] for j in range(2)] for k in range(2)]
ans = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            worth = 0
            for x, y, z in cake:
                if i == 1:
                    x = -x
                if j == 1:
                    y = -y
                if k == 1:
                    z = -z
                box[i][j][k].append(x + y + z)
            box[i][j][k].sort(reverse=True)
            ans = max(ans, sum(box[i][j][k][:m]))
print(ans)

-x = [] -y = [] -z = [] -for i in range(n): -    X, Y, Z = list(map(int, input().split())) -    x.append(X) -    y.append(Y) -    z.append(Z) -sign = [1, -1] -ans = [] -for j in sign: -    for k in sign: -        for l in sign: -            a = [] -            for i in range(n): -                a.append(x[i] * j + y[i] * k + z[i] * l) -            a.sort(reverse=True) -            ans.append(sum(a[:m])) -print((max(ans))) +cake = [list(map(int, input().split())) for i in range(n)] +box = [[[[] for i in range(2)] for j in range(2)] for k in range(2)] +ans = 0 +for i in range(2): +    for j in range(2): +        for k in range(2): +            worth = 0 +            for x, y, z in cake: +                if i == 1: +                    x = -x +                if j == 1: +                    y = -y +                if k == 1: +                    z = -z +                box[i][j][k].append(x + y + z) +            box[i][j][k].sort(reverse=True) +            ans = max(ans, sum(box[i][j][k][:m])) +print(ans)