#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s1 = 0, su = 0, point = 0;
  cin >> m >> n;
  int a[n];
  int b[n];
  memset(b, 0, sizeof(b));
  int sum[m];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[j];
    }
    a[0] = a[0] + b[0];
    for (int k = 1; k < n; k++) {
      a[k] = max(b[k], a[k - 1]) + a[k];
    }
    sum[i] = a[n - 1];
    for (int i = 0; i < n; i++) {
      b[i] = a[i];
    }
  }
  for (int i = 0; i < m; i++) {
    cout << sum[i] << " ";
  }
}
