#include <bits/stdc++.h>
using namespace std;
int m, n, input[50000][5];
int main(int argc, char** argv) {
  int i, j, k, dp, output;
  while (scanf(" %d%d", &n, &m) == 2) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        scanf(" %d", &input[i][j]);
      }
    }
    dp = 0;
    for (i = 0; i < m; i++) {
      dp += input[0][i];
      input[0][i] = dp;
    }
    dp = 0;
    for (i = 0; i < n; i++) {
      dp += input[i][0];
      input[i][0] = dp;
    }
    for (i = 1; i < n; i++) {
      for (j = 1; j < m; j++) {
        if (input[i][j - 1] <= input[i - 1][j]) {
          input[i][j] = input[i - 1][j] + input[i][j];
        } else {
          input[i][j] = input[i][j - 1] + input[i][j];
        }
      }
    }
    for (i = 0; i < n; i++) {
      printf("%d ", input[i][m - 1]);
    }
    printf("\n");
  }
  return 0;
}
