#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  return (a < b) ? gcd(b, a) : ((a % b == 0) ? b : gcd(b, a % b));
}
bool isprime(long long x) {
  for (long long i = 2; i <= sqrt(x); i++)
    if (!(x % i)) return false;
  return true;
}
ifstream fin("input.txt");
ofstream fout("output.txt");
long long m, n, a[51000][5], dp[51000][5];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> m >> n;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  dp[0][0] = a[0][0];
  for (int i = 1; i < n; i++) dp[0][i] = dp[0][i - 1] + a[0][i];
  for (int i = 1; i < m; i++) dp[i][0] = dp[i - 1][0] + a[i][0];
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++)
      dp[j][i] = max(dp[j - 1][i], dp[j][i - 1]) + a[j][i];
  for (int i = 0; i < m; i++) cout << dp[i][n - 1] << " ";
  return 0;
}
