from sys import stdin

nii=lambda:list(map(int,stdin.readline().split()))

lnii=lambda:list(map(int,stdin.readline().split()))



n,m=nii()

l=[lnii() for i in range(n)]



ans=0

for i in range(2**3):

  t_l=[]

  for j in l:

    t_num=0

    for k in range(3):

      if (i>>k)&1:

        t_num+=j[k]

      else:

        t_num-=j[k]

    t_l.append(t_num)



  t_l.sort(reverse=True)

  ans=max(ans,sum(t_l[:m]))



print(ans)
from sys import stdin

nii=lambda:list(map(int,stdin.readline().split()))

lnii=lambda:list(map(int,stdin.readline().split()))



n,m=nii()

l=[lnii() for i in range(n)]



ans=0

for i in [1,-1]:

  for j in [1,-1]:

    for k in [1,-1]:

      t_num=0

      t_l=[]

      for x,y,z in l:

        t_num=x*i+y*j+z*k

        t_l.append(t_num)

      t_l.sort(reverse=True)

      ans=max(ans,sum(t_l[:m]))



print(ans)
from sys import stdin

nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
n, m = nii()
l = [lnii() for i in range(n)]
ans = 0
for i in range(2**3):
    t_l = []
    for j in l:
        t_num = 0
        for k in range(3):
            if (i >> k) & 1:
                t_num += j[k]
            else:
                t_num -= j[k]
        t_l.append(t_num)
    t_l.sort(reverse=True)
    ans = max(ans, sum(t_l[:m]))
print(ans)

from sys import stdin

nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
n, m = nii()
l = [lnii() for i in range(n)]
ans = 0
for i in [1, -1]:
    for j in [1, -1]:
        for k in [1, -1]:
            t_num = 0
            t_l = []
            for x, y, z in l:
                t_num = x * i + y * j + z * k
                t_l.append(t_num)
            t_l.sort(reverse=True)
            ans = max(ans, sum(t_l[:m]))
print(ans)

-for i in range(2**3): -    t_l = [] -    for j in l: -        t_num = 0 -        for k in range(3): -            if (i >> k) & 1: -                t_num += j[k] -            else: -                t_num -= j[k] -        t_l.append(t_num) -    t_l.sort(reverse=True) -    ans = max(ans, sum(t_l[:m])) +for i in [1, -1]: +    for j in [1, -1]: +        for k in [1, -1]: +            t_num = 0 +            t_l = [] +            for x, y, z in l: +                t_num = x * i + y * j + z * k +                t_l.append(t_num) +            t_l.sort(reverse=True) +            ans = max(ans, sum(t_l[:m]))