#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, dp[50001][6];
  while (~scanf("%d%d", &m, &n)) {
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= m; ++i)
      for (int j = 1; j <= n; ++j) scanf("%d", &dp[i][j]);
    for (int i = 1; i <= m; ++i)
      for (int j = 1; j <= n; ++j)
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + dp[i][j];
    for (int i = 1; i < m; ++i) printf("%d ", dp[i][n]);
    printf("%d\n", dp[m][n]);
  }
  return 0;
}
