#include<iostream>
using namespace std;

int main()
{
    int h;
    int n;
    cin>>h>>n;
    int gl_niz[n];
    for (int i=0; i<n; i++)
    {
        gl_niz[i] = 1;
    }

    int red = 1;
    for (int red = 1; red <= h; red++)
    {
        int pom_niz[n];
        for (int i=0; i<n; i++)
        {
            int input;
            cin>>input;
            pom_niz[i] = input;
        }
        for (int i=0; i<n; i++)
        {
            if (pom_niz[i] != 1)
            {
                if((i == 0) || (i == n-1))
                {
                    if (i==0)
                    {
                        int ind = i;
                        while (pom_niz[ind] != 1)
                            ind++;
                        gl_niz[ind] += 1;
                        gl_niz[0] = 0;

                    }
                    else
                    {
                        int ind = n-1;
                        while (pom_niz[ind] != 1)
                            ind--;
                        gl_niz[ind] += 1;
                        gl_niz[0] = 0;
                    }
                }
                else
                {
                    int deo = gl_niz[i] / 2;
                    int ost = gl_niz[i] % 2;
                    int ind_desno = i;
                    int ind_levo = i;
                    while (pom_niz[ind_desno] != 1)
                    {
                        ind_desno++;
                    }
                    while (pom_niz[ind_levo] != 1)
                    {
                        ind_levo--;
                    }
                    gl_niz[ind_desno] += deo;
                    gl_niz[ind_levo] += deo;
                    if (red % 2 == 0)
                    {
                        gl_niz[ind_desno] += ost;
                    }
                    else
                    {
                        gl_niz[ind_levo] += ost;
                    }
                }
            }
        }
    }

    for (int i=0; i<n; i++)
    {
        cout<<gl_niz[i]<<" ";
    }
    return 0;
}