#include <bits/stdc++.h>
using namespace std;
int main() {
  int p[7] = {0};
  int pic[60000] = {0};
  int n, m;
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int ii = 0; ii < n; ii++) {
      int x;
      cin >> x;
      if (ii) {
        p[ii] = max(p[ii - 1], p[ii]) + x;
      } else {
        p[ii] += x;
      }
    }
    pic[i] = p[n - 1];
  }
  for (int i = 0; i < m; i++) {
    if (i) cout << ' ';
    cout << pic[i];
  }
  return 0;
}
