#include <bits/stdc++.h>
using namespace std;
int a[50010][5];
int dp[50010][5];
int main() {
  int n, m;
  int i, j;
  cin >> n >> m;
  memset((dp), (0), sizeof((dp)));
  int t1 = 0, t2 = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> a[i][j];
      if (i == 0) {
        t2 += a[0][j];
        dp[0][j] = t2;
      }
    }
    t1 += a[i][0];
    dp[i][0] = t1;
  }
  for (i = 1; i < n; i++)
    for (j = 1; j < m; j++) {
      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
    }
  for (i = 0; i < n; i++) {
    cout << dp[i][m - 1] << " ";
  }
}
