#include <bits/stdc++.h>
using namespace std;
int dp[50004][8];
int main() {
  int m, n;
  cin >> m >> n;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) cin >> dp[i][j];
  }
  for (int i = 1; i <= m; i++) dp[i][1] += dp[i - 1][1];
  for (int i = 1; i <= n; i++) dp[1][i] += dp[1][i - 1];
  for (int i = 2; i <= m; i++) {
    for (int j = 2; j <= n; j++) {
      if (dp[i - 1][j] >= dp[i][j - 1])
        dp[i][j] += dp[i - 1][j];
      else
        dp[i][j] += dp[i][j - 1];
    }
  }
  for (int i = 1; i <= m; i++) cout << dp[i][n] << " ";
  return 0;
}
