#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, temp;
  cin >> m >> n;
  vector<vector<int> > v(m);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> temp;
      v[i].push_back(temp);
    }
  }
  vector<vector<int> > ans(m);
  ans[0].push_back(v[0][0]);
  for (int i = 1; i < n; i++) {
    ans[0].push_back(ans[0][i - 1] + v[0][i]);
  }
  for (int i = 1; i < m; i++) {
    ans[i].push_back(ans[i - 1][0] + v[i][0]);
    for (int j = 1; j < n; j++) {
      ans[i].push_back(max(ans[i - 1][j], ans[i][j - 1]) + v[i][j]);
    }
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i][n - 1] << " ";
  }
  cout << endl;
  return 0;
}
