#include <bits/stdc++.h>
using namespace std;
int m, n, t[50001][6], a[50001][6];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  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 <= n; i++) {
    for (int j = 1; j <= m; j++) {
      a[j][i] = max(a[j - 1][i], a[j][i - 1]) + t[j][i];
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << a[i][n] << "\n";
  }
  return 0;
}
