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