#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long m, n, i, j;
  cin >> m >> n;
  vector<vector<long long>> t(m);
  for (i = 0; i < m; ++i) {
    for (j = 0; j < n; ++j) {
      t[i].push_back(0);
      cin >> t[i][j];
    }
  }
  for (j = 1; j < n; ++j) t[0][j] += t[0][j - 1];
  cout << t[0][n - 1] << " ";
  for (i = 1; i < m; ++i) {
    for (j = 0; j < n; ++j) {
      if (j == 0)
        t[i][j] += t[i - 1][j];
      else {
        t[i][j] += max(t[i][j - 1], t[i - 1][j]);
      }
    }
    cout << t[i][n - 1] << " ";
  }
  return 0;
}
