#include <bits/stdc++.h>
int main() {
  int m, n, i, j, k = 0, t = 0, x = 0;
  int a[50010][10] = {0}, b[50010] = {0}, c[50010][10] = {0};
  scanf("%d %d", &m, &n);
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (j = 0; j < n; j++) {
    t += a[0][j];
    c[0][j] = t;
  }
  for (j = 0; j < n; j++) x += a[0][j];
  b[k] = x;
  k++;
  for (i = 1; i < m; i++) {
    for (j = 0; j < n; j++) {
      c[i][j] += c[i - 1][j] + a[i][j];
      if (j != 0 && c[i - 1][j] < c[i][j - 1])
        c[i][j] += c[i][j - 1] - c[i - 1][j];
    }
  }
  for (i = 0; i < m; i++) printf("%d ", c[i][n - 1]);
  printf("\n");
  return 0;
}
