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