#include <bits/stdc++.h>
using namespace std;
const int OO = (int)2e9;
const double eps = 1e-9;
const int inf = 1e2;
bool com(const pair<int, int>& p1, const pair<int, int>& p2) {
  return p1.second < p2.second;
}
int arr[50005][5];
int finish[5000005];
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int m, n;
  long long total = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    int time = 0;
    for (int j = 0; j < n; j++) {
      int begin = max(time, finish[j]);
      finish[j] = begin + arr[j][i];
      time = finish[j];
    }
  }
  for (int i = 0; i < n; i++) cout << finish[i] << " ";
  return 0;
}
