#include <iostream>

using namespace std;

void raspodela(int a[], int p, int k, int zbir, int i, int n)
{
    if(p==0)a[k]+=zbir;
    else if(k==(n+1))a[p]+=zbir;
    else if(zbir%2==0)
    {
        a[p]+=zbir/2;
        a[k]+=zbir/2;
    }
    else
    {
        if(i%2==0)
        {
            a[k]+=zbir/2+1;
            a[p]+=zbir/2;
        }
        else
        {
            a[k]+=zbir/2;
            a[p]+=zbir/2+1;
        }
    }
}

int main()
{
    int h,n,p=0,k,zbir=0;
    cin>>h>>n;
    int m[h][n], a[n];
    for(int i=0;i<=n;i++)
        a[i]=1;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=n;j++)
            cin>>m[i][j];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(m[i][j]==1)
            {
                if(m[i][j-1]==0 && j!=1)
                {
                    k=j;
                    raspodela(a,p,k,zbir,i,n);
                    zbir=0;
                }
                if(m[i][j+1]==0 && j!=n)p=j;
            }
            if(m[i][j]==0)
            {
                zbir+=a[j];
                a[j]=0;
                if(j==n)
                {
                    raspodela(a,p,n+1,zbir,i,n);
                    zbir=0;
                }
            }
        }
    }
    for(int i=1;i<=n;i++)cout<<a[i]<<" ";
    cout<<endl;
}