#include <bits/stdc++.h>
using namespace std;
long long ar[50005 + 5][6], br[50005 + 5][6], fr[300], cnt;
int main() {
  long long i, j, k, f, m, n;
  while (cin >> m >> n) {
    f = 1;
    for (i = 1; i <= m; i++) {
      for (j = 1; j <= n; j++) {
        cin >> ar[i][j];
        br[i][j] = ar[i][j];
      }
    }
    for (i = 1; i <= n; i++) ar[1][i] += ar[1][i - 1];
    for (i = 1; i <= m; i++) ar[i][1] += ar[i - 1][1];
    for (j = 2; j <= n; j++) {
      for (i = 2; i <= m; i++) {
        ar[i][j] += max(ar[i][j - 1], ar[i - 1][j]);
      }
    }
    for (i = 1; i <= m; i++) {
      cout << ar[i][n] << " ";
    }
    cout << endl;
  }
  return 0;
}
