#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
double EPS = 1e-9;
void swaps(char *x, char *y) {
  char temp;
  temp = *x;
  *x = *y;
  *y = temp;
}
void swapi(int *a, int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == 1 || b == 1) return 1;
  if (a == b) return a;
  if (a > b)
    return gcd(b, a % b);
  else
    return gcd(a, b % a);
}
int checkpaintings(int m, int n, int a[50000][5], int ans[], int &time,
                   int &k) {
  for (int i = k; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] > 0) return k;
    }
    {
      k++;
      ans[i] = time;
    }
  }
  return k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m;
  cin >> m;
  int n;
  cin >> n;
  int paintingTime[m][n];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) cin >> paintingTime[i][j];
  }
  vector<int> finishTime(m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (j == 0) {
        finishTime[j] += paintingTime[j][i];
      } else {
        finishTime[j] = ((finishTime[j - 1] + paintingTime[j][i]) >
                                 (finishTime[j] + paintingTime[j][i])
                             ? (finishTime[j - 1] + paintingTime[j][i])
                             : (finishTime[j] + paintingTime[j][i]));
      }
    }
  for (auto x : finishTime) cout << x << ' ';
  return 0;
}
