#include <bits/stdc++.h>
using namespace std;
int freq[100003];
void solve() {
  int n, m;
  cin >> m >> n;
  int mat[m][n], sum[m][n];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) cin >> mat[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i == 0) {
        if (j != 0) {
          mat[j][i] += mat[j - 1][i];
        }
      } else {
        if (j == 0) {
          mat[j][i] += mat[j][i - 1];
        } else {
          if (mat[j][i - 1] > mat[j - 1][i]) {
            mat[j][i] += mat[j - 1][i] + (mat[j][i - 1] - mat[j - 1][i]);
          } else {
            mat[j][i] += mat[j - 1][i];
          }
        }
      }
    }
  }
  for (int i = 0; i < m; i++) cout << mat[i][n - 1] << " ";
  cout << "\n";
}
int main() {
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
