#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
const long long N = 1e6 + 6;
void solve() {
  long long n, m;
  cin >> n >> m;
  long long arr[n + 1][m + 1];
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) cin >> arr[i][j];
  }
  long long dp[n + 1][m + 1];
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      if (i == 0 || j == 0)
        dp[i][j] = 0;
      else {
        if (j == 1)
          dp[i][j] = dp[i - 1][j] + arr[i][j];
        else {
          if (dp[i][j - 1] <= dp[i - 1][j]) {
            dp[i][j] = dp[i - 1][j] + arr[i][j];
          } else {
            dp[i][j] = dp[i - 1][j] + arr[i][j] + (dp[i][j - 1] - dp[i - 1][j]);
          }
        }
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << dp[i][m] << " ";
    ;
  }
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
