#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int n, m;
int f[N][10];
int g[N][10];
int main() {
  cin >> m >> n;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &f[i][j]);
    }
  }
  for (int i = 0; i < m; ++i) {
    g[i + 1][0] = g[i][0] + f[i][0];
    for (int j = 1; j < n; ++j) {
      g[i + 1][j] = max(g[i + 1][j - 1] + f[i][j], g[i][j] + f[i][j]);
    }
    printf("%d ", g[i + 1][n - 1]);
  }
}
