#include <bits/stdc++.h>
using namespace std;
int ans[50005];
int t[50005][5];
int finishtime[5][50005];
int main() {
  int m, n;
  cin >> m >> n;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) cin >> t[i][j];
  int a = 0;
  finishtime[0][0] = t[0][0];
  for (int i = 1; i < m; i++) finishtime[0][i] = t[i][0] + finishtime[0][i - 1];
  for (int i = 1; i < n; i++) {
    finishtime[i][0] = finishtime[i - 1][0] + t[0][i];
    for (int j = 1; j < m; j++)
      finishtime[i][j] =
          max(finishtime[i - 1][j], finishtime[i][j - 1]) + t[j][i];
  }
  for (int i = 0; i < m; i++) cout << finishtime[n - 1][i] << ' ';
  return 0;
}
