#include <bits/stdc++.h>
using namespace std;
int ar[50002][6];
int z[6];
int main() {
  int m, n;
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) cin >> ar[i][j];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (j == 0)
        z[j] = z[j] + ar[i][j];
      else
        z[j] = max(z[j] + ar[i][j], z[j - 1] + ar[i][j]);
    }
    cout << z[n - 1] << " ";
  }
  cout << endl;
  return 0;
}
