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