import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, m; readV(n, m);
  long[] x, y, z; readC(n, x, y, z);

  auto r = -10L^^18;
  foreach (p; 0..1<<3) {
    auto sx = p.bitTest(0) ? 1 : -1;
    auto sy = p.bitTest(1) ? 1 : -1;
    auto sz = p.bitTest(2) ? 1 : -1;

    auto dp = new long[][](n+1, m+1);
    foreach (dpi; dp) dpi[] = -10L^^18;
    dp[0][0] = 0;

    foreach (i; 0..n)
      foreach (j; 0..m+1) {
        dp[i+1][j] = dp[i][j];
        if (j > 0)
          dp[i+1][j] = max(dp[i+1][j], dp[i][j-1]+x[i]*sx+y[i]*sy+z[i]*sz);
      }

    r = max(r, dp[n][m]);
  }

  writeln(r);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}
