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