#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
int Map[50002][7];
int main() {
  int m, n;
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &Map[i][j]);
  for (int i = 1; i <= m; i++) Map[i][1] += Map[i - 1][1];
  for (int j = 1; j <= n; j++) Map[1][j] += Map[1][j - 1];
  for (int i = 2; i <= m; i++)
    for (int j = 2; j <= n; j++) Map[i][j] += max(Map[i - 1][j], Map[i][j - 1]);
  for (int i = 1; i <= m; i++) {
    if (i > 1) putchar(' ');
    printf("%d", Map[i][n]);
  }
  puts("");
}
