using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace prog_Ik_3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] u = Console.ReadLine().Split();
            int h = Convert.ToInt32(u[0]);
            int n = Convert.ToInt32(u[1]);

            int[] p = new int[n];
            
            string[] s = new string[n];
            int[] r = new int[n];

            for (int i = 0; i < n; i++)
                p[i] = 1;

            bool ulaz = false;
            int ip=0, ik=n;
            

            for(int i=0;i<h;i++)
            {
                s = Console.ReadLine().Split();
                for (int k = 0; k < n; k++)
                {
                    if(s[k] == "0" && !ulaz)
                    {
                        ip = k;
                        ulaz = true;
                    }
                    if(s[k] == "1" || (k==n-1))
                    {
                        if (ulaz)
                        {
                            ik = k;
                            if (ip < 1)
                            {
                                for (int zov = ip; zov < ik; zov++)
                                {
                                    p[ik] += p[zov];
                                    p[zov] = 0;
                                }
                            }
                            else if ((ik > n - 2) && (s[ik]=="0"))
                            {
                                for (int zov = ip; zov < ik+1; zov++)
                                {
                                    p[ip-1] += p[zov];
                                    p[zov] = 0;
                                }
                            }
                            else
                            {
                                for (int zov = ip; zov < ik ; zov++)
                                {
                                    p[ip - 1] += p[zov]/2;
                                    p[ik] += p[zov] / 2;
                                    if (i % 2 == 0)
                                        p[ip - 1] += p[zov] % 2;
                                    else
                                        p[ik] += p[zov] % 2;
                                    p[zov] = 0;
                                }
                            }
                            ulaz = false;

                        }

                    }

                }

            }
            for (int e = 0; e < n-1; e++)
                Console.Write(p[e] + " ");
            Console.WriteLine(p[n - 1]);

            

        }
    }
}