using System;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            string red;
            red = Console.ReadLine();
            var h = red[0] - '0' + 1;
            var n = red[2] - '0'; ;
            int brojac;
            int[,] matrica = new int[h, n];
            for (int i = 1; i < h; i ++)
            {
                red = Console.ReadLine();
                brojac = 0;
                for (int j = 0; j < n; j++)
                {
                    matrica[i, j] = red[brojac] - '0' - 1;
                    brojac += 2;
                }
            }
            for (int j = 0; j < n; j++)
                matrica[0, j] = 1;
            for (int i = 0; i < h - 1; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if(matrica[i, j] >= 0)
                    {
                        if(matrica[i + 1, j] >= 0)
                        {
                            matrica[i + 1, j] += matrica[i, j];
                        }
                        else
                        {
                            bool levi = false;
                            bool desni = false;
                            int lindex = 0;
                            int dindex = 0;
                            for (int k = 1; k < n; k++)
                            {
                                if (!levi && !desni)
                                {
                                    if (j - k >= 0 && !levi)
                                    {
                                        if (matrica[i + 1, j - k] >= 0)
                                        {
                                            levi = true;
                                            lindex = j - k;
                                        }
                                    }
                                    if (j + k < n && !desni)
                                    {
                                        if (matrica[i + 1, j + k] >= 0)
                                        {
                                            desni = true;
                                            dindex = j + k;
                                        }
                                    }
                                }
                            }
                            
                            if (levi && desni)
                            {
                                Console.WriteLine("Oba");
                                matrica[i + 1, lindex] += matrica[i, j] / 2;
                                matrica[i + 1, dindex] += matrica[i, j] / 2;
                                if (matrica[i, j] % 2 != 0)
                                {
                                    if (i % 2 == 0)
                                    {
                                        matrica[i + 1, lindex] += 1;
                                    }
                                    else
                                    {
                                        matrica[i + 1, dindex] += 1;
                                    }
                                }
                            }
                            else if (levi)
                            {
                                Console.WriteLine("levi");
                                matrica[i + 1, lindex] += matrica[i, j];
                            }
                            else if (desni)
                            {
                                Console.WriteLine("desni");
                                matrica[i + 1, dindex] += matrica[i, j];
                            }
                        }
                    }
                    else
                    {
                        //if(matrica[i + 1, j] > 0)
                            //matrica[i + 1, j] -= 1;
                    }
                }
            }
            for (int j = 0; j < n; j++)
            {
                if (matrica[h - 1, j] < 0)
                    matrica[h - 1, j] = 0;
                Console.Write(matrica[h - 1, j]  + " ");
            }
        }
    }
}