#include <bits/stdc++.h>
using namespace std;
int t[50005][6];
int dp[50005][6];
int n, m;
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 <= m; i++) {
    for (int j = 1; j <= n; j++)
      dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]) + t[i][j];
  }
  for (int i = 1; i <= m; i++) cout << dp[i][n] << " ";
  cout << endl;
  return 0;
}
