#include <bits/stdc++.h>
using namespace std;
const int maxn = 5 * 100 * 100 + 10;
long long a[maxn][6];
long long b[maxn][6];
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) cin >> a[i][j];
  int res = 0;
  for (long long i = 1; i <= n; i++) {
    res += a[i][1];
    b[i][1] = res;
  }
  res = 0;
  for (long long j = 1; j <= m; j++) {
    res += a[1][j];
    b[j][1] = res;
  }
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++)
      b[i][j] = max(b[i - 1][j], b[i][j - 1]) + a[i][j];
  for (long long i = 1; i <= n; i++) cout << b[i][m] << ' ';
  cout << endl;
  return 0;
}
