#include <bits/stdc++.h>
using namespace std;
const int maxm = 50000 + 20, maxn = 7;
int n, m, a[maxm][maxn];
int main() {
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int j = 1; j < n + 1; j++) {
      cin >> a[i][j];
    }
  }
  for (int j = 0; j < n; j++) {
    for (int i = 1; i < m; i++) {
      a[i - 1][j + 1] += a[i - 1][j];
      if (a[i][j] < a[i - 1][j + 1]) {
        a[i][j] = a[i - 1][j + 1];
      }
    }
    a[m - 1][j + 1] += a[m - 1][j];
  }
  for (int i = 0; i < m; i++) {
    cout << a[i][n] << " ";
  }
  return 0;
}
