output_description: Print the maximum possible value of (the absolute value of the total beauty) +
  (the absolute value of the total tastiness) + (the absolute value of the total
  popularity) for the set of cakes that Ringo chooses.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      x_1 y_1 z_1
      x_2 y_2 z_2
       :  :
      x_N y_N z_N
attempt: ###############################################################################
  
  from sys import stdout
  from bisect import bisect_left as binl
  from copy import copy, deepcopy
  from collections import defaultdict
  
  
  mod = 1
  
  
  def intin():
      input_tuple = input().split()
      if len(input_tuple) <= 1:
          return int(input_tuple[0])
      return tuple(map(int, input_tuple))
  
  
  def intina():
      return [int(i) for i in input().split()]
  
  
  def intinl(count):
      return [intin() for _ in range(count)]
  
  
  def modadd(x, y):
      global mod
      return (x + y) % mod
  
  
  def modmlt(x, y):
      global mod
      return (x * y) % mod
  
  
  def lcm(x, y):
      while y != 0:
          z = x % y
          x = y
          y = z
      return x
  
  
  def combination(x, y):
      assert x >= y
  
      if y > x // 2:
          y = x - y
  
      ret = 1
  
      for i in range(0, y):
          j = x - i
          i = i + 1
  
          ret = ret * j
          ret = ret // i
  
      return ret
  
  
  def get_divisors(x):
      retlist = []
      for i in range(1, int(x**0.5) + 3):
          if x % i == 0:
              retlist.append(i)
              retlist.append(x // i)
      return retlist
  
  
  def get_factors(x):
      retlist = []
      for i in range(2, int(x**0.5) + 3):
          while x % i == 0:
              retlist.append(i)
              x = x // i
      retlist.append(x)
      return retlist
  
  
  def make_linklist(xylist):
      linklist = {}
      for a, b in xylist:
          linklist.setdefault(a, [])
          linklist.setdefault(b, [])
          linklist[a].append(b)
          linklist[b].append(a)
      return linklist
  
  
  def calc_longest_distance(linklist, v=1):
      distance_list = {}
      distance_count = 0
      distance = 0
      vlist_previous = []
      vlist = [v]
      nodecount = len(linklist)
  
      while distance_count < nodecount:
          vlist_next = []
          for v in vlist:
              distance_list[v] = distance
              distance_count += 1
              vlist_next.extend(linklist[v])
          distance += 1
          vlist_to_del = vlist_previous
          vlist_previous = vlist
          vlist = list(set(vlist_next) - set(vlist_to_del))
  
      max_distance = -1
      max_v = None
      for v, distance in distance_list.items():
          if distance > max_distance:
              max_distance = distance
              max_v = v
  
      return (max_distance, max_v)
  
  
  def calc_tree_diameter(linklist, v=1):
      _, u = calc_longest_distance(linklist, v)
      distance, _ = calc_longest_distance(linklist, u)
      return distance
  
  
  ###############################################################################
  
  
  def f(slist, m):
      slist.sort()
  
      xsum = ysum = zsum = 0
  
      for _, x, y, z in slist[:m]:
          xsum += x
          ysum += y
          zsum += z
  
      return abs(xsum) + abs(ysum) + abs(zsum)
  
  
  def main():
      n, m = intin()
      xyzlist = intinl(n)
  
      ans = -float("inf")
  
      slist = [(x + y + z, x, y, z) for x, y, z in xyzlist]
      ans = max(ans, f(slist, m))
  
      slist = [(-x + y + z, x, y, z) for x, y, z in xyzlist]
      ans = max(ans, f(slist, m))
  
      slist = [(x - y + z, x, y, z) for x, y, z in xyzlist]
      ans = max(ans, f(slist, m))
  
      slist = [(x + y - z, x, y, z) for x, y, z in xyzlist]
      ans = max(ans, f(slist, m))
  
      slist = [(-x - y + z, x, y, z) for x, y, z in xyzlist]
      ans = max(ans, f(slist, m))
  
      slist = [(x - y - z, x, y, z) for x, y, z in xyzlist]
      ans = max(ans, f(slist, m))
  
      slist = [(-x + y - z, x, y, z) for x, y, z in xyzlist]
      ans = max(ans, f(slist, m))
  
      slist = [(-x - y - z, x, y, z) for x, y, z in xyzlist]
      ans = max(ans, f(slist, m))
  
      print(ans)
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  Takahashi became a pastry chef and opened a shop _La Confiserie d'ABC_ to
  celebrate AtCoder Beginner Contest 100.
  
  The shop sells N kinds of cakes.  
  Each kind of cake has three parameters "beauty", "tastiness" and "popularity".
  The i-th kind of cake has the beauty of x_i, the tastiness of y_i and the
  popularity of z_i.  
  These values may be zero or negative.
  
  Ringo has decided to have M pieces of cakes here. He will choose the set of
  cakes as follows:
  
    * Do not have two or more pieces of the same kind of cake.
    * Under the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).
  
  Find the maximum possible value of (the absolute value of the total beauty) +
  (the absolute value of the total tastiness) + (the absolute value of the total
  popularity) for the set of cakes that Ringo chooses.
samples: [{"input": "5 3\n    3 1 4\n    1 5 9\n    2 6 5\n    3 5 8\n    9 7 9", "output": "56\n    \n\nConsider having the 2-nd, 4-th and 5-th kinds of cakes. The total beauty,\ntastiness and popularity will be as follows:\n\n  * Beauty: 1 + 3 + 9 = 13\n  * Tastiness: 5 + 5 + 7 = 17\n  * Popularity: 9 + 8 + 9 = 26\n\nThe value (the absolute value of the total beauty) + (the absolute value of\nthe total tastiness) + (the absolute value of the total popularity) here is 13\n+ 17 + 26 = 56. This is the maximum value.\n\n* * *"}, {"input": "5 3\n    1 -2 3\n    -4 5 -6\n    7 -8 -9\n    -10 11 -12\n    13 -14 15", "output": "54\n    \n\nConsider having the 1-st, 3-rd and 5-th kinds of cakes. The total beauty,\ntastiness and popularity will be as follows:\n\n  * Beauty: 1 + 7 + 13 = 21\n  * Tastiness: (-2) + (-8) + (-14) = -24\n  * Popularity: 3 + (-9) + 15 = 9\n\nThe value (the absolute value of the total beauty) + (the absolute value of\nthe total tastiness) + (the absolute value of the total popularity) here is 21\n+ 24 + 9 = 54. This is the maximum value.\n\n* * *"}, {"input": "10 5\n    10 -80 21\n    23 8 38\n    -94 28 11\n    -26 -2 18\n    -69 72 79\n    -26 -86 -54\n    -72 -50 59\n    21 65 -32\n    40 -94 87\n    -62 18 82", "output": "638\n    \n\nIf we have the 3-rd, 4-th, 5-th, 7-th and 10-th kinds of cakes, the total\nbeauty, tastiness and popularity will be -323, 66 and 249, respectively.  \nThe value (the absolute value of the total beauty) + (the absolute value of\nthe total tastiness) + (the absolute value of the total popularity) here is\n323 + 66 + 249 = 638. This is the maximum value.\n\n* * *"}, {"input": "3 2\n    2000000000 -9000000000 4000000000\n    7000000000 -5000000000 3000000000\n    6000000000 -1000000000 8000000000", "output": "30000000000\n    \n\nThe values of the beauty, tastiness and popularity of the cakes and the value\nto be printed may not fit into 32-bit integers."}]