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

max = -float('inf')

x = []

y = []

z = []

for i in range(N):

	xx,yy,zz = list(map(int,input().split()))

	x.append(xx)

	y.append(yy)

	z.append(zz)

for i in range(-1,2,2):

	for j in range(-1,2,2):

		for k in range(-1,2,2):

			s = []

			for m in range(N):

				s.append(i*x[m]+j*y[m]+k*z[m])

			s = sorted(s)

			tmp = sum(s[-1*M:])

			if tmp > max:

				max = tmp

if M==0:

	print((0))

else:

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

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

res = 0

for a in (1,-1):

    for b in (1,-1):

        for c in (1,-1):

            l = []

            for (x,y,z) in xyz:

                l.append(x*a+y*b+z*c)

            l = sorted(l,reverse=True)

            res = max(res, sum(l[:m]))

print(res)

N, M = list(map(int, input().split()))
max = -float("inf")
x = []
y = []
z = []
for i in range(N):
    xx, yy, zz = list(map(int, input().split()))
    x.append(xx)
    y.append(yy)
    z.append(zz)
for i in range(-1, 2, 2):
    for j in range(-1, 2, 2):
        for k in range(-1, 2, 2):
            s = []
            for m in range(N):
                s.append(i * x[m] + j * y[m] + k * z[m])
            s = sorted(s)
            tmp = sum(s[-1 * M :])
            if tmp > max:
                max = tmp
if M == 0:
    print((0))
else:
    print(max)

n, m = list(map(int, input().split()))
xyz = [list(map(int, input().split())) for _ in range(n)]
res = 0
for a in (1, -1):
    for b in (1, -1):
        for c in (1, -1):
            l = []
            for (x, y, z) in xyz:
                l.append(x * a + y * b + z * c)
            l = sorted(l, reverse=True)
            res = max(res, sum(l[:m]))
print(res)

-N, M = list(map(int, input().split())) -max = -float("inf") -x = [] -y = [] -z = [] -for i in range(N): -    xx, yy, zz = list(map(int, input().split())) -    x.append(xx) -    y.append(yy) -    z.append(zz) -for i in range(-1, 2, 2): -    for j in range(-1, 2, 2): -        for k in range(-1, 2, 2): -            s = [] -            for m in range(N): -                s.append(i * x[m] + j * y[m] + k * z[m]) -            s = sorted(s) -            tmp = sum(s[-1 * M :]) -            if tmp > max: -                max = tmp -if M == 0: -    print((0)) -else: -    print(max) +n, m = list(map(int, input().split())) +xyz = [list(map(int, input().split())) for _ in range(n)] +res = 0 +for a in (1, -1): +    for b in (1, -1): +        for c in (1, -1): +            l = [] +            for (x, y, z) in xyz: +                l.append(x * a + y * b + z * c) +            l = sorted(l, reverse=True) +            res = max(res, sum(l[:m])) +print(res)