#include <bits/stdc++.h>
using namespace std;
long long arr[50009][9];
int main() {
  long long n, m, ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> arr[i][j];
  for (int i = 2; i <= n; i++) arr[i][1] += arr[i - 1][1];
  for (int i = 2; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (j != 1) {
        arr[j][i] += max(arr[j][i - 1], arr[j - 1][i]);
      } else
        arr[j][i] += arr[j][i - 1];
    }
  }
  for (int i = 1; i <= n; i++) cout << arr[i][m] << " ";
  return 0;
}
