#include <iostream>
#include <vector>
using namespace std;

int n, h;
vector<vector<int> > pad;
vector<int> protok;
int f(int i,int j)
{
    if(j==0)
        return 1;
    if(j==h-1)
        return 2;
    if((i+1)%2==0)
        return 3;
    if((i+1)%2==1)
        return 4;
}
int main() {
    
    cin>>n>>h;
    for(int i=0;i<n;i++)
    {
        vector<int> vek;
        for(int j=0;j<h;j++)
        {
            int p;
            if(i==0)
                protok.push_back(1);
            cin>>p;
            if(p==0)
                vek.push_back(1);
            else vek.push_back(0);
        }
        pad.push_back(vek);
    }/*
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<h;j++)
        {
            cout<<pad[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
            for(int l=0;l<h;l++)
            {
                cout<<protok[l]<<" ";
            }
            cout<<endl;*/
    for(int i=0;i<n;i++)
    {
        int pocetak=-1,kraj=-1,suma=0;
        for(int j=0;j<h;j++)
        {
            if(pad[i][j]==1)
            {
                if(pocetak==-1)
                    {pocetak=j;kraj=j;}
                suma+=protok[j];
                
                switch(f(i,j))
                {
                    case 1:
                        if(j+1<=n-1 && pad[i][j+1]==1)
                        {
                            kraj+=1;
                            protok[j]=0;
                        }
                        else
                        {
                            protok[kraj+1]+=suma;
                            protok[j]=0;
                            suma=0;pocetak=-1;kraj=-1;
                        }
                        break;
                    case 2:
                        if(j+1<=n-1 && pad[i][j+1]==1)
                        {
                            kraj+=1;
                            protok[j]=0;
                        }
                        else
                        {
                            protok[pocetak-1]+=suma;
                            //cout<<endl<<"pocetak-1 "<<pocetak-1<<" j "<<j <<"kraj "<<kraj<<"    suma "<<suma<<endl;
                            protok[j]=0;
                            suma=0;pocetak=-1;kraj=-1;
                        }
                        break;
                    case 3:
                        if(j+1<=n-1 && pad[i][j+1]==1)
                        {
                            kraj+=1;
                            //cout<<endl<<"case 3 if"<<" j "<<j <<" pocetak-1 "<<pocetak-1<<"kraj "<<kraj<<"    suma "<<suma<<endl;
                            protok[j]=0;
                        }
                        else
                        {
                            protok[kraj+1]+=suma/2+suma%2;
                            protok[pocetak-1]+=suma/2;
                            protok[j]=0;
                            //cout<<endl<<"case 3 else"<<" j "<<j <<" pocetak-1 "<<pocetak<<"kraj "<<kraj<<"    suma "<<suma<<endl;
                            suma=0;pocetak=-1;kraj=-1;
                        }
                        break;
                    case 4:
                        if(j+1<=n-1 && pad[i][j+1]==1)
                        {
                            kraj+=1;
                            protok[j]=0;
                        }
                        else
                        {
                            protok[kraj+1]+=suma/2;
                            protok[pocetak-1]+=suma/2+suma%2;
                            protok[j]=0;
                            suma=0;pocetak=-1;kraj=-1;
                        }
                        break;
                }
            }
        }
            /*for(int l=0;l<h;l++)
            {
                cout<<protok[l]<<" ";
            }
            cout<<endl;*/
    }
       
    for(int i=0;i<h;i++)
    {
        cout<<protok[i]<<" ";
    }
    return 0;
}
/*
5 7
1 1 1 1 0 0 0
1 0 1 0 1 0 1
1 1 0 0 0 1 0
1 0 0 1 1 0 1
0 1 1 0 1 1 0*/
/*
3 3 
1 1 0
1 0 1
0 1 1
*/