#include<bits/stdc++.h>
using namespace std;

struct index
{
    int levo;
    int desno;
};

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int h,n,o,l,indexVodopada,dodaj;
    cin >> h >> n;
    vector<vector<bool> > v(h,vector<bool> (n));
    vector<vector<index> > vodopadi(h,vector<index> (n));
    stack<int> s;
    for (int i=0;i<h;i++)
    {
        l=-1;
        for (int j=0;j<n;j++)
        {
            cin >> o;
            if(o==1)
            {
                v[i][j]=true;//vodopad
                while(!s.empty())
                {
                    indexVodopada=s.top();
                    vodopadi[i][indexVodopada].levo=l;
                    vodopadi[i][indexVodopada].desno=j;
                    s.pop();
                }
                l=j;
            }
            else if(o==0)
            {
                v[i][j]=false;//stena
                s.push(j);
            }
        }
        while(!s.empty())
        {
            indexVodopada=s.top();
            vodopadi[i][indexVodopada].levo=l;
            vodopadi[i][indexVodopada].desno=-2;
            s.pop();
        }
    }
    vector<int> resenje(n,1);
    for (int i=0;i<h;i++)
        for (int j=0;j<n;j++)
        {
            if(v[i][j]==false && resenje[j]>0)
            {
                if(vodopadi[i][j].levo==-1)
                {
                    resenje[vodopadi[i][j].desno]+=resenje[j];
                    resenje[j]=0;
                }
                else if(vodopadi[i][j].desno==-2)
                {
                    resenje[vodopadi[i][j].levo]+=resenje[j];
                    resenje[j]=0;
                }
                else
                {
                    dodaj=resenje[j]/2;
                    resenje[vodopadi[i][j].desno]+=dodaj;
                    resenje[vodopadi[i][j].levo]+=dodaj;
                    if(resenje[j]%2==1)
                    {
                        if(i%2==0)
                            resenje[vodopadi[i][j].levo]++;
                        else
                            resenje[vodopadi[i][j].desno]++;
                    }
                    resenje[j]=0;
                }
            }
        }
    for (int i=0;i<n;i++)
        cout << resenje[i] << " ";
}