#include <bits/stdc++.h>
int main() {
  int pic, painter, x, y;
  scanf("%d%d", &pic, &painter);
  int ar[50001][6];
  for (x = 1; x <= pic; x++)
    for (y = 1; y <= painter; y++) scanf("%d", &ar[x][y]);
  int fin[pic + 1][painter + 1];
  for (x = 1; x <= pic; x++)
    for (y = 1; y <= painter; y++) fin[x][y] = 0;
  fin[1][1] = ar[1][1];
  for (x = 2; x <= pic; x++) {
    fin[x][1] = fin[x - 1][1] + ar[x][1];
  }
  for (y = 2; y <= painter; y++) {
    fin[1][y] = fin[1][y - 1] + ar[1][y];
  }
  for (x = 2; x <= pic; x++) {
    for (y = 2; y <= painter; y++) {
      if (fin[x - 1][y] > fin[x][y - 1])
        fin[x][y] = ar[x][y] + fin[x - 1][y];
      else
        fin[x][y] = ar[x][y] + fin[x][y - 1];
    }
  }
  for (x = 1; x <= pic; x++) printf("%d ", fin[x][painter]);
  return 0;
}
