#include <bits/stdc++.h>
using namespace std;
int DP[6];
int t[6];
int main() {
  int m, n;
  while (~scanf("%d%d", &m, &n)) {
    memset(DP, 0, sizeof(DP));
    for (int i = 0; i < m; i++) {
      for (int j = 1; j <= n; j++) {
        scanf("%d", &t[j]);
      }
      for (int j = 1; j <= n; j++) {
        DP[j] = max(DP[j - 1] + t[j], DP[j] + t[j]);
      }
      if (i == m - 1) {
        printf("%d\n", DP[n]);
      } else {
        printf("%d ", DP[n]);
      }
    }
  }
  return 0;
}
