#include <bits/stdc++.h>
using namespace std;
int a[50000][5];
int b[50000][5];
int main() {
  int m, n, i, j, time, flag;
  while (scanf("%d%d", &m, &n) != EOF) {
    time = 0;
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++) {
        scanf("%d", &a[i][j]);
        b[i][j] = a[i][j];
        if (i == 0 && j != 0) b[i][j] += b[i][j - 1];
        if (j != 0 && i != 0) {
          if (b[i][j - 1] > b[i - 1][j]) {
            b[i][j] += b[i][j - 1] - b[i - 1][j];
          }
        }
        if (i != 0) b[i][j] += b[i - 1][j];
      }
    }
    for (i = 0; i < m; i++) {
      if (i) printf(" ");
      printf("%d", b[i][n - 1]);
    }
    printf("\n");
  }
  return 0;
}
