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