#include using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) using ll = long long; int main(){ ll n, m; cin >> n >> m; vector s(m); ll a[n][m]; rep(i,n) { rep(j,m) { cin >> a[i][j]; s[j] += a[i][j]; } } vector value(n); rep(i,n) { rep(j,m) value[i] += s[j]*a[i][j]; } sort(value.begin(),value.end(),greater()); ll ans = 0; rep(i,n) { if(i % 2 == 0) ans += value[i]; else ans -= value[i]; } cout << ans << endl; return 0; }