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