#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
int Factorial(ll n)
{
	for (ll i = n - 1; i > 1; i--)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll Combination(const ll n, const ll r)
{
	return Factorial(n) / (Factorial(r) * Factorial(n - r));
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool IsPrime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll DigitSum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

int main()
{
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll n, m;
	vll x, y, z;
	multiset<ll> s000, s001, s010, s011, s100, s101, s110, s111;
	REP(i, n)
	{
		inll x_, y_, z_;
		x.push_back(x_);
		y.push_back(y_);
		z.push_back(z_);
		s000.insert(x_ + y_ + z_);
		s001.insert(x_ + y_ + -z_);
		s010.insert(x_ + -y_ + z_);
		s011.insert(x_ + -y_ + -z_);
		s100.insert(-x_ + y_ + z_);
		s101.insert(-x_ + y_ + -z_);
		s110.insert(-x_ + -y_ + z_);
		s111.insert(-x_ + -y_ + -z_);
	}

	ll res000 = 0;
	auto it = s000.rbegin();
	REP(i, m)
	{
		res000 += *(it++);
	}

	ll res001 = 0;
	auto it1 = s001.rbegin();
	REP(i, m)
	{
		res001 += *(it1++);
	}

	ll res010 = 0;
	auto it2 = s010.rbegin();
	REP(i, m)
	{
		res010 += *(it2++);
	}

	ll res011 = 0;
	auto it3 = s011.rbegin();
	REP(i, m)
	{
		res011 += *(it3++);
	}

	ll res100 = 0;
	auto it4 = s100.rbegin();
	REP(i, m)
	{
		res100 += *(it4++);
	}

	ll res101 = 0;
	auto it5 = s101.rbegin();
	REP(i, m)
	{
		res101 += *(it5++);
	}

	ll res110 = 0;
	auto it6 = s110.rbegin();
	REP(i, m)
	{
		res110 += *(it6++);
	}

	ll res111 = 0;
	auto it7 = s111.rbegin();
	REP(i, m)
	{
		res111 += *(it7++);
	}

	return OUT(max({res000, res001, res010, res011, res100, res101, res110, res111}));
}


Measured memory_bytes: 640