import sys input = sys.stdin.readline def main(): N,M = map(int,input().split()) A = [tuple(map(int,input().split())) for _ in range(N)] X = [0] * M C = [0]*M for i in range(N): for j in range(M): C[j] += A[i][j] used = [False] * N for i in range(N): if i%2 == 0: M = 0 idx = -1 for j in range(N): if used[j]: continue ret = sum((a + b)*c for a,b,c in zip(A[j],X,C)) if ret > M: ret = M idx = j X = [x + a for x,a in zip(X,A[idx])] used[idx] = True else: M = 0 idx = -1 for j in range(N): if used[j]: continue ret = sum((a - b)*c for a,b,c in zip(A[j],X,C)) if ret < M: ret = M idx = j X = [x - a for x,a in zip(X,A[idx])] used[idx] = True ans = sum(x*c for x,c in zip(X,C)) print(ans) if __name__ == '__main__': main()