#include <iostream>
#include <vector>
#include <stdio.h>

#define MAXNH 1000000
//obavezno promeniti

using namespace std;

void ispis(int x[],int n)
{
    for(int i=0;i<n;i++)
        cout<<x[i]<<" ";
}

void f(int s[],int x[],int n,bool nep)
{
    //cout<<nep<<endl;
    int l[MAXNH],d[MAXNH],pred=-1,xc[MAXNH],tr=0;
    for(int i=0;i<n;i++)
        xc[i]=0;
    for(int i=0;i<n;i++)
        if(s[i])
        {
            pred=i;
            l[i]=i;
        }
        else
            l[i]=pred;
    pred=-1;
    for(int i=n-1;i>=0;i--)
        if(s[i])
        {
            pred=i;
            d[i]=i;
        }
        else
            d[i]=pred;
    /*ispis(s,n);
    cout<<endl;
    /*ispis(l,n);
    cout<<endl;
    ispis(d,n);
    cout<<endl<<endl;*/
    for(int i=0;i<n;i++)
    {
        /*ispis(xc,n);
        cout<<endl;*/
        if(s[i]==1)
            xc[i]+=x[i];
        else{
            tr=0;
            while(i<n&&s[i]==0)
            {
                tr+=x[i];
                i++;
            }
            //cout<<tr<<" ";
            i--;
            if(l[i]==-1)
                xc[d[i]]+=tr;
            else
                if(d[i]==-1)
                    xc[l[i]]+=tr;
                else
                {
                    xc[l[i]]+=tr/2;
                    xc[d[i]]+=tr/2;
                    if(nep)
                        xc[l[i]]+=tr%2;
                    else
                        xc[d[i]]+=tr%2;
                }
        }
    }
    for(int i=0;i<n;i++)
        x[i]=xc[i];

    //cout<<endl<<endl;
}

int main()
{
    int h,n,x[MAXNH];
    int s[MAXNH];
    char c;
    scanf("%d %d",&h,&n);
    //cout<<h<<" "<<n<<" "<<n*h<<endl;
    for(int i=0;i<n*h;i++){
        scanf("%d",&s[i]);
    }
    for(int i=0;i<n;i++)
        x[i]=1;
    //cout<<endl;
    for(int i=0;i<h;i++){
        /*ispis(x,n);
        cout<<endl;*/
        f(s+n*i,x,n,!i%2);
    }
    ispis(x,n);

    return 0;
}