#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int m, n, input[50005][10], arr[50005][10];
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> input[i][j];
    }
  }
  long long answer = 0;
  for (int i = 0; i < n; i++) {
    answer += input[0][i];
    arr[0][i] = input[0][i];
  }
  cout << answer << " ";
  for (int i = 1; i < m; i++) {
    answer = 0;
    for (int j = 0; j < n; j++) {
      long long remainder = 0, compare = input[i][j];
      arr[i][j] = input[i][j] + arr[i - 1][j];
      for (int k = j; k < n - 1; k++) {
        if (arr[i - 1][k + 1] > compare) {
          arr[i - 1][k + 1] -= compare;
          compare = 0;
        }
        if (arr[i - 1][k + 1] <= compare) {
          compare -= arr[i - 1][k + 1];
          arr[i - 1][k + 1] = 0;
        }
        if (compare == 0) break;
      }
    }
    for (int j = 0; j < n; j++) answer += arr[i][j];
    cout << answer << " ";
  }
  return 0;
}
