#include using namespace std; using vi = vector; void solve(){ int n, m; cin >> n >> m; int ans = 0, minimum = INT_MAX; vector< vi > arr(n, vector(m)); for( int i = 0; i < n; ++i ){ for( int j = 0; j < m; ++j){ cin >> arr[i][j]; ans += arr[i][j]; if ( (i == j)) continue; if (arr[i][j] < minimum ) minimum = arr[i][j]; } } if ( n % 2 == 1 || m % 2 == 1){ cout << ans << endl; return; } cout << ans - minimum << endl; return; } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int t = 1; //cin >> t; while (t--){ solve(); } return 0; }