#include <bits/stdc++.h>
using namespace std;
int a[50001][6];
int max(int x, int y) {
  int z = (x > y) ? x : y;
  return z;
}
int main() {
  int m, n, i, j;
  cin >> m >> n;
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++) cin >> a[i][j];
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++) a[i][j] = max(a[i - 1][j], a[i][j - 1]) + a[i][j];
  for (i = 1; i <= m; i++) cout << a[i][n] << " ";
  return 0;
}
