#include <bits/stdc++.h>
using namespace std;
int n, m;
long long time2[6][50002];
long long finished[6][50002];
int main() {
  cin >> n;
  cin >> m;
  for (int k = 1; k <= n; k++) {
    for (int k2 = 1; k2 <= m; k2++) {
      cin >> time2[k2][k];
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int k2 = 1; k2 <= m; k2++) {
      finished[k2][k] =
          max(finished[k2][k - 1], finished[k2 - 1][k]) + time2[k2][k];
    }
  }
  for (int k = 1; k <= n; k++) {
    cout << finished[m][k] << " ";
  }
}
