#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
const unsigned int MOD = 1000000007;
template <class T>
T power(T a, long long int n) {
  T res = 1;
  while (n > 0) {
    if (n % 2) res = res * a;
    a = a * a, n = n / 2;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int m, n;
  cin >> m >> n;
  vector<vector<int> > arr(m + 1, vector<int>(n + 1, 0));
  vector<vector<int> > ans(m + 1, vector<int>(n + 1, 0));
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) cin >> arr[i][j];
  ans[1][1] = arr[1][1];
  for (int i = 1; i <= m; i++) {
    ans[i][1] = arr[i][1] + ans[i - 1][1];
    for (int j = 2; j <= n; j++) {
      if (ans[i - 1][j] < ans[i][j - 1])
        ans[i][j] = ans[i][j - 1] + arr[i][j];
      else
        ans[i][j] = ans[i - 1][j] + arr[i][j];
    }
  }
  for (int i = 1; i <= m; i++) cout << ans[i][n] << " ";
}
