#include <bits/stdc++.h>
using namespace std;
int m, n, sum = 0, s, t;
int arr[50001][6];
int main() {
  cin >> m >> n;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) cin >> arr[i][j];
  }
  if (n == 1) {
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= n; j++) {
        sum += arr[i][j];
        arr[i][j] = sum;
      }
    }
  } else {
    for (int i = 1; i <= n; i++) {
      sum += arr[1][i];
      arr[1][i] = sum;
    }
    sum = 0;
    for (int i = 1; i <= m; i++) {
      sum += arr[i][1];
      arr[i][1] = sum;
    }
    for (int i = 2; i <= m; i++) {
      for (int j = 1; j <= n - 1; j++) {
        if (arr[i][j] >= arr[i - 1][j + 1]) {
          t = arr[i][j] + arr[i][j + 1];
          arr[i][j + 1] = t;
        } else {
          s = arr[i - 1][j + 1] + arr[i][j + 1];
          arr[i][j + 1] = s;
        }
      }
    }
  }
  for (int i = 1; i <= m; i++) cout << arr[i][n] << " ";
  return 0;
}
