package main
import (
"bufio"
"io"
"os"
"strconv"
)
func main() {
data, _ := io.ReadAll(os.Stdin)
idx := 0
nextInt := func() int {
for idx < len(data) && data[idx] <= ' ' {
idx++
}
num := 0
for idx < len(data) && data[idx] > ' ' {
num = num*10 + int(data[idx]-'0')
idx++
}
return num
}
m := nextInt()
n := nextInt()
dp := make([]int64, n+1)
out := make([]byte, 0, m*12)
for i := 0; i < m; i++ {
for j := 1; j <= n; j++ {
t := int64(nextInt())
if dp[j] < dp[j-1] {
dp[j] = dp[j-1]
}
dp[j] += t
}
out = strconv.AppendInt(out, dp[n], 10)
if i+1 < m {
out = append(out, ' ')
}
}
w := bufio.NewWriterSize(os.Stdout, len(out)+1)
w.Write(out)
w.Flush()
}