#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  t = 1;
  while (t--) {
    long long num1, num2;
    cin >> num1 >> num2;
    vector<vector<int> > arr(num1, (vector<int>(num2, 0)));
    for (int i = 0; i < num1; ++i)
      for (int j = 0; j < num2; ++j) cin >> arr[i][j];
    vector<vector<int> > dp(num1, (vector<int>(num2, 0)));
    dp[0][0] = arr[0][0];
    for (int i = 1; i < num2; ++i) dp[0][i] = dp[0][i - 1] + arr[0][i];
    for (int i = 1; i < num1; ++i) dp[i][0] = dp[i - 1][0] + arr[i][0];
    for (int i = 1; i < num1; ++i)
      for (int j = 1; j < num2; ++j) {
        dp[i][j] = arr[i][j] + max(dp[i][j - 1], dp[i - 1][j]);
      }
    for (int i = 0; i < num1; ++i) cout << dp[i][num2 - 1] << " ";
    cout << endl;
  }
  return 0;
}
