#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m >> n;
  long long int store[m][n];
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> store[i][j];
    }
  }
  for (int i = 1; i < m; ++i) store[i][0] += store[i - 1][0];
  for (int i = 1; i < n; ++i) store[0][i] += store[0][i - 1];
  for (int i = 1; i < m; ++i) {
    for (int j = 1; j < n; ++j) {
      store[i][j] += max(store[i - 1][j], store[i][j - 1]);
    }
  }
  for (int i = 0; i < m; ++i) cout << store[i][n - 1] << " ";
}
