using System;
class Program
{
    static void Main(string[] args)
    {
        string[] x = Console.ReadLine().Split(' ');
        int h = int.Parse(x[0]), n = int.Parse(x[1]);
        int[,] a = new int[h, n];
        for (int i = 0; i < h; i++)
        {
            string[] c = Console.ReadLine().Split(' ');
            for (int j = 0; j < n; j++)
            {
                a[i, j] = int.Parse(c[j]);
            }
        }
        int[] b1 = new int[n], b2 = new int[n];
        for(int i = 0; i < n; i++)
        {
            b1[i] = 1;
        }
        int hm = 0;
        while (hm < h)
        {

            for (int i = 0; i < n; i++)
            {
                b2[i] = a[hm, i];
            }
            bool a1 = false;
            while (a1 == false)
            {
                a1 = true;
                for (int i = 0; i < n; i++)
                {
                    if (b1[i] != 0 && b2[i] == 0)
                    {
                        a1 = false;
                    }
                }
                for (int i = 0; i < n && a1 == false; i++)
                {
                    int bmax=-1, bmin=-1;
                    if (b2[i] == 0)
                    {
                        for(int j=i-1; j>=0 && bmin == -1; j--)
                        {
                            if(b2[j] == 1)
                            {
                                bmin = j;
                            }
                        }
                        for (int j = i+1 ; j <= n-1 && bmax == -1; j++)
                        {
                            if (b2[j] == 1)
                            {
                                bmax = j;
                            }
                        }
                        if (bmax == -1)
                        {
                            b1[bmin] += b1[i];
                        }
                        else if (bmin == -1)
                        {
                            b1[bmax] += b1[i];
                        }
                        else if ( bmin != -1 && bmax != -1)
                        {
                            b1[bmin] += b1[i] / 2 + ((hm + 1) % 2) * b1[i]%2;
                            b1[bmax] += b1[i] / 2 + (hm % 2) * b1[i] % 2;
                        }
                        b1[i] = 0;
                    }
                    
                }
                
            }
            hm++;
        }
        for(int i = 0; i < n; i++)
        {
            Console.Write(b1[i] + " ");
        }
    }
}