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