#include <bits/stdc++.h>
using namespace std;
int dp[50005][10];
int main() {
  int n, m, val;
  cin >> m >> n;
  int v[m + 5][n + 5];
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> v[i][j];
    }
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int cur_start = max(dp[j - 1][i], dp[j][i - 1]);
      dp[j][i] = cur_start + v[j][i];
    }
  }
  for (int i = 1; i <= m; i++) cout << dp[i][n] << " \n"[i == m];
  return 0;
}
