#include <bits/stdc++.h>
using namespace std;
inline int min(int x, int y) { return x < y ? x : y; }
inline int max(int x, int y) { return x > y ? x : y; }
int a[60000][6];
int t[60000][6];
int main() {
  int m, n;
  cin >> m >> n;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == 0 && j == 0) {
        t[i][j] = a[i][j];
      } else if (i == 0) {
        t[i][j] = t[i][j - 1] + a[i][j];
      } else if (j == 0) {
        t[i][j] = t[i - 1][j] + a[i][j];
      } else {
        t[i][j] = max(t[i - 1][j], t[i][j - 1]) + a[i][j];
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    if (i) cout << " ";
    cout << t[i][n - 1];
  }
  cout << endl;
  return 0;
}
