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