#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return (a == 0) ? b : (b == 0) ? a : gcd(b, a % b); }
int str_div(char *s, int n) {
  int y = 0, ln = strlen(s);
  for (int i = 0; i < ln; ++i) y = (y * 10 + (s[i] - 48)) % n;
  return y;
}
int get() {
  int y, s = 1, i = 10;
  y = 0;
  char c = getchar();
  while (!(c >= 48 && c <= 57)) {
    if (c == '-') s = -1;
    c = getchar();
  }
  while ((c >= 48 && c <= 57))
    y = (y << 1) + (y << 3) + (c & 15), c = getchar();
  if (c != '.') return y * s;
  c = getchar();
  while ((c >= 48 && c <= 57))
    y = y + (c & 15) / i, i = (i << 1) + (i << 3), c = getchar();
  return y * s;
}
int dx[] = {1, -1, 0, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 0, -1, 1, -1, 1};
int arr[55000][7];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < m + 1; ++j) {
      int num = get();
      arr[i][j] = max(arr[i - 1][j], arr[i][j - 1]) + num;
    }
    printf("%d ", arr[i][m]);
  }
}
