#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main()
{
    ll h, n;
    cin>>h>>n;
    ll vodopad[h][n], protok[h][n] = {0};
    for(ll i=0; i<h; ++i)
    {
        for(ll j=0; j<n; ++j)
        {
            cin>>vodopad[i][j];
            protok[i][j]=0;
        }
    }

    for(ll i=0; i<n; ++i)
        protok[0][i]=1;

    for(ll i=0; i<h; ++i)
    {
        for(ll j=0; j<n;)
        {
            //cout<<"j: "<<j<<"\n";
            //Trenutno nije ispod stene
            if(i>0)
            {
                if(vodopad[i-1][j]==1)
                    protok[i][j]+=protok[i-1][j];
            }
            ll brojac=1, temp, trenProt;
            bool vise=false;
            //Trenutno stena
            if(vodopad[i][j]==0)
            {

                trenProt=protok[i][j];

                //Trenutno VISE stena, prebroj ih.
                if(vodopad[i][j+1]==0)
                {
                    vise=true;
                    //Prebrojava stene u trenutnoj vezanoj gomili.
                    for(int k=j+1; k<n; ++k)
                    {
                        if(vodopad[i][k]==0)
                            brojac++;
                        else if(vodopad[i][k]==1)
                            break;

                    }
                    for(int k=j-1; k>-1; --k)
                    {
                        if(vodopad[i][k]==0)
                            brojac++;
                        else if(vodopad[i][k]==1)
                            break;
                        brojac++;
                    }
                }
                ll leva=j-1, desna=j+brojac;
                /*cout<<"brojac: "<<brojac<<"\n";
                if(vise)
                    cout<<"vise\n";
                else
                    cout<<"jedna\n";
                cout<<"leva: "<<leva<<" desna: "<<desna<<"\n";*/
                //Leva ivica
                if(j==0)
                {
                    //Jedna stena
                    if(!vise)
                    {
                        protok[i][j+1]+=trenProt;
                    }
                    //Vise stena
                    else
                    {
                        if(i>0)
                        {
                            temp=trenProt;
                            for(ll k=j; k<n-brojac; ++k)
                            {
                                temp+=protok[i-1][k];
                            }
                            protok[i][desna]+=temp;
                        }
                        else if(i==0)
                        {
                            temp=trenProt;
                            temp += brojac;
                            protok[i][desna]+=temp;
                        }
                    }

                }
                //Desna ivica
                else if(j==n-1 || j+brojac>n-1)
                {
                    //Jedna stena
                    if(!vise)
                    {
                        protok[i][j-1]+=trenProt;
                    }
                    //Vise stena
                    else
                    {
                        //cout<<"desno, vise\n";
                        if(i==0)
                        {
                            temp=0;
                            temp += brojac;
                            //cout<<"protok[i][leva] "<<protok[i][leva]<<"\n";
                            protok[i][leva]+=temp;
                        }
                        else
                        {
                            temp=trenProt;
                            for(ll k=j; k>j-brojac; --k)
                            {
                                temp+=protok[i-1][k];
                            }
                            protok[i][leva]+=temp;
                        }
                    }
                }
                //Nije ivica
                else if(j>0 && j<n)
                {
                    //cout<<"J: "<<j<<endl;
                    //cout<<"SREDINA\n";
                    //Jedna stena
                    if(!vise)
                    {

                        //cout<<"jedna u sredini trenprot: "<<trenProt<<"\n";
                        if(i>0)
                        {
                            trenProt=protok[i-1][j];
                        }
                        //Protok neparan
                        if(trenProt%2==1)
                        {
                            trenProt--;
                            if((i+1)%2==1)
                                protok[i][leva]++;
                            else
                                protok[i][desna]++;
                        }
                        //svakako polovine dodaj na levu i desnu stranu
                        trenProt/=2;
                        //cout<<"polovina: "<<trenProt<<"\n";
                        protok[i][leva]+=trenProt;
                        protok[i][desna]+=trenProt;
                    }
                    //Vise stena
                    else if(vise)
                    {
                        temp=0;
                        for(ll k=j; k<j+brojac; ++k)
                        {
                            temp+=protok[i-1][k];
                        }
                        //cout<<"Vise, sredina, temp: "<<temp<<endl;
                        //Protok (temp) neparan
                        if(temp%2==1)
                        {
                            temp--;
                            if((i+1)%2==1)
                                protok[i][leva]++;
                            else
                                protok[i][desna]++;
                        }
                        //svakako polovine dodaj na levu i desnu stranu
                        temp/=2;
                        protok[i][leva]+=temp;
                        protok[i][desna]+=temp;
                    }
                }
                for(int k=j; k<j+brojac; ++k)
                    protok[i][k]=0;
            }
            j+=brojac;
            //for(int k=j; k<j+brojac; ++k)
            // protok[i][k]=0;
        }
        //cout<<"\n";
    }
    /*for(ll i=0; i<h; ++i)
    {
        for(ll j=0; j<n; ++j)
        {
            cout<<protok[i][j]<<" ";
        }
        cout<<"\n";
    }*/
    //cout<<"\n";
    for(ll i=0; i<n; ++i)
    {
        cout<<protok[h-1][i]<<" ";
    }
    cout<<"\n";
    return 0;
}