#include <bits/stdc++.h>
using namespace std;
bool prime[100000 + 1];
void sieve() {
  memset(prime, true, sizeof(prime));
  for (long p = 2; p * p <= 100000; p++) {
    if (prime[p] == true) {
      for (long i = p * p; i <= 100000; i += p) prime[i] = false;
    }
  }
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long power(int v, int a) {
  long long prod = 1;
  for (int i = 0; i < a; i++) prod *= v;
  return prod;
}
int l(unsigned long long val) {
  int cnt = 1;
  unsigned long long a = 2;
  while (a * 2 <= val) {
    a = a * 2;
    cnt++;
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    int m, n, temp;
    cin >> m >> n;
    int a[n];
    memset(a, 0, sizeof(a));
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        cin >> temp;
        if (j == 0)
          a[j] += temp;
        else {
          a[j] = max(a[j - 1], a[j]) + temp;
        }
      }
      cout << a[n - 1] << " ";
    }
  }
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
