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