#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int h,n;
void ispis(int **x)
{
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=n;j++)
            cout<<x[i][j]<<" ";
        cout<<endl;
    }
}
int main()
{
    cin>>h>>n;

    int **x=new int *[h+1];
    for (int i=0;i<h+1;i++)
        x[i]=new int[n];

    for(int i=1;i<=h;i++)
        for(int j=1;j<=n;j++)
                scanf("%i",&x[i][j]);

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

    for(int i=1;i<=h;i++)
        x[h][0]=1;

    int **y=new int *[h+1];
    for (int i=0;i<h+1;i++)
        y[i] =new int[n];

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

    for(int i=1;i<=h;i++)
        y[h][0]=1;

    for(int i=1;i<=h;i++)
        for(int j=1;j<=n;j++)
            y[i][j]=0;

    int l,d;
    for(int i=1;i<=h;i++)
    {
        l=0;
        d=0;
        int suma_desno=0;
        int suma=0;
        int suma_levo=0;
        for(int j=1;j<=n;j++)
        {
            if(x[i][j]==1)
            {
                y[i][j]=y[i-1][j];
                if(x[i][j-1]==0)
                {
                    if(i%2==1)
                    {
                        suma_desno=suma/2;
                        suma_levo=suma-suma_desno;
                    }
                    else
                    {
                        suma_levo=suma/2;
                        suma_desno=suma-suma_levo;
                    }
                    y[i][j]+=suma_desno;
                    suma_desno=0;
                    if(l>0)
                        y[i][l]+=suma_levo;
                    else
                        y[i][j]+=suma_levo;
                    suma_levo=0;
                    suma=0;
                }
                l=j;
            }
            else
                if(x[i][j]==0)
                        suma+=y[i-1][j];
            if(j==n)
                y[i][l]+=suma;
        }
    }
    for(int i=1;i<=n;i++)
        cout<<y[h][i]<<" ";
}