using System;
using System.Collections.Generic;

namespace Tak_Prog_Isplata
{
    class Program
    {
        static void Main(string[] args)
        {

            int h;
            int n;
            string s;
            string[] a;
            s = Console.ReadLine();
            a = s.Split();
            int brojac=0;
            h = int.Parse(a[0]);
            n = int.Parse(a[1]);
            int[,] mat1 = new int[h, n];
            for (int i = 0; i < h; i++)
            {
                string b;
                string[] c;
                b = Console.ReadLine();
                c = b.Split();

                for (int j = 0; j < c.Length; j++)
                {
                    mat1[i, j] = int.Parse(c[j]);
                }

            }
            for (int i = 0; i < n; i++)
            {
                brojac = 0;
                if (mat1[h-1, i] != 0)
                {
                    if (i != 0 && i != n - 1)
                    {
                        if (mat1[h - 2, i - 1] == 1) brojac++;
                        if (mat1[h - 2, i] == 1) brojac++;
                        if (mat1[h - 2, i + 1] == 1) brojac++;

                       
                    }
                    else
                    {
                        if (i==0)
                        {
                            if (mat1[h - 2, i] == 1) brojac++;
                            if (mat1[h - 2, i + 1] == 1) brojac++;
                        }
                        
                        if (i==n-1)
                        {
                            if (mat1[h - 2, i] == 1) brojac++;
                            if (mat1[h - 2, i - 1] == 1) brojac++;
                        }
                    }
                }
                

                Console.Write(brojac + " ");
            }






        }
    }
}