#include <bits/stdc++.h>
using namespace std;
int arr[50000 + 10][5 + 10];
int main() {
  int m, n, t;
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (i == 0 && j == 0) continue;
      if (j != 0 && i == 0) {
        arr[i][j] += arr[i][j - 1];
      } else if (j == 0 && i != 0) {
        arr[i][j] += arr[i - 1][j];
      } else {
        arr[i][j] += max(arr[i][j - 1], arr[i - 1][j]);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    cout << arr[i][n - 1] << " ";
  }
  return 0;
}
