#include <bits/stdc++.h>
int p[50010][6] = {0};
int max(int a, int b) { return a > b ? a : b; }
int main() {
  int m, n, i, j;
  scanf("%d%d", &m, &n);
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++) {
      scanf("%d", &p[i][j]);
      p[i][j] += max(p[i - 1][j], p[i][j - 1]);
    }
  for (i = 1; i <= m; i++) printf("%d ", p[i][n]);
  printf("\n");
  return 0;
}
