#include <bits/stdc++.h>
using namespace std;
int r[5][50000];
int main() {
  cin.sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> r[j][i];
  for (int i = 0; i < n - 1; ++i) r[0][i + 1] += r[0][i];
  for (int i = 0; i < m - 1; ++i) r[i + 1][0] += r[i][0];
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      r[j][i] += max(r[j - 1][i], r[j][i - 1]);
    }
  }
  for (int i = 0; i < n; ++i) cout << r[m - 1][i] << " ";
  cout << endl;
  return 0;
}
