#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)5e5 + 10;
int a[MAX][7];
int memo[MAX][7];
int main() {
  int m, n;
  scanf("%d", &m);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    a[1][i] = t;
  }
  for (int i = 2; i <= m; i++) {
    for (int q = 1; q <= n; q++) {
      int t;
      scanf("%d", &t);
      a[i][q] = a[i - 1][q] + t;
    }
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    memo[1][i] = memo[1][i - 1] + a[1][i];
  }
  for (int i = 1; i <= n; i++) {
    sum += a[1][i];
  }
  printf("%d ", sum);
  for (int row = 2; row <= m; row++) {
    for (int col = 1; col <= n; col++) {
      if (col == 1) {
        memo[row][1] = a[row][1];
      } else {
        memo[row][col] = max(memo[row - 1][col], memo[row][col - 1]) +
                         a[row][col] - a[row - 1][col];
      }
    }
  }
  for (int i = 2; i <= m; i++) {
    printf("%d ", memo[i][n]);
  }
  puts("");
  return 0;
}
