#include <bits/stdc++.h>
using namespace std;
const int max_n = 6;
int t, dp[2][max_n], n, m;
int main() {
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> t;
      dp[i % 2][j] = t;
      if (i) dp[i % 2][j] = max(dp[i % 2][j], dp[(i + 1) % 2][j] + t);
      if (j) dp[i % 2][j] = max(dp[i % 2][j], dp[i % 2][j - 1] + t);
    }
    cout << dp[i % 2][n - 1] << " ";
  }
  return 0;
}
