#include <bits/stdc++.h>
const long long INF = 1e13;
const double pi = acos(-1);
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  long long m, n;
  cin >> m >> n;
  vector<vector<long long> > v(m, vector<long long>(n));
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) cin >> v[i][j];
  for (int i = 1; i < n; i++) v[0][i] += v[0][i - 1];
  for (int i = 1; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (j > 0) {
        v[i][j] += max(v[i - 1][j], v[i][j - 1]);
      } else {
        v[i][j] += v[i - 1][j];
      }
    }
  }
  for (int i = 0; i < m; i++) cout << v[i][n - 1] << ' ';
  return 0;
}
