#include //#include //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector vec; typedef vector mat; ll N,M,H,W,Q,K,A,B; string S; typedef pair P; const ll INF = (1LL<<58); template bool chmin(T &a, const T &b){ if(a > b) {a = b; return true;} else return false; } template bool chmax(T &a, const T &b){ if(a < b) {a = b; return true;} else return false; } int main() { cin>>N>>M; vec score(N); rep(i,N){ vec temp(M); rep(j, M) cin>>temp[j]; score[i] = accumulate(ALL(temp), 0LL); } vec dp(2, 0); dp[1] = -INF; rep(i,N){ ll temp = max(dp[1], dp[0] + score[i]); chmax(dp[0], dp[1] - score[i]); chmax(dp[1], temp); } cout<