#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  while (scanf("%d %d", &m, &n) == 2) {
    int ara[n + 5][m + 5];
    int ans[m + 5];
    int before = 0;
    ans[1] = 0;
    ara[1][0] = ara[2][0] = ara[3][0] = ara[4][0] = ara[5][0] = ara[0][1] = 0;
    for (int i = 1; i <= m; i++) {
      ara[0][i] = 0;
      for (int j = 1; j <= n; j++) {
        scanf("%d", &ara[j][i]);
        ara[j][i] = ara[j][i] + max(ara[j][i - 1], ara[j - 1][i]);
      }
      ans[i] = ara[n][i];
    }
    for (int i = 1; i <= m; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
