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