#include <bits/stdc++.h>
using namespace std;
template <class T>
string tostring(T x) {
  ostringstream out;
  out << x;
  return out.str();
}
long long toint(string s) {
  istringstream in(s);
  long long x;
  in >> x;
  return x;
}
int t[50001][6];
int ans[50001];
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];
    }
  }
  int tmp = 0;
  for (int i = 0; i < m; i++) {
    ans[i] = tmp + t[i][0];
    tmp = ans[i];
  }
  for (int i = 1; i < n; i++) {
    tmp = 0;
    for (int j = 0; j < m; j++) {
      if (tmp <= ans[j]) {
        ans[j] = ans[j] + t[j][i];
        tmp = ans[j];
      } else {
        ans[j] = t[j][i] + ans[j - 1];
        tmp = ans[j];
      }
    }
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
