#include <bits/stdc++.h>
using namespace std;
int ans[100005] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int m, n;
  cin >> m >> n;
  int a[m][n];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (i == 0 && j == 0) continue;
      if (i > 0 && j > 0)
        a[i][j] += max(a[i - 1][j], a[i][j - 1]);
      else if (i == 0 && j > 0)
        a[i][j] += a[i][j - 1];
      else
        a[i][j] += a[i - 1][j];
    }
  }
  for (int i = 0; i < m; i++) cout << a[i][n - 1] << " ";
  return 0;
}
