#include<bits/stdc++.h>
#define MAXN (int)1e6+10
using namespace std;
int n, h;
int niz[MAXN];
int res[MAXN];
int main()
{
    cin >> h >> n;
    for(int i=0;i<n;i++)res[i]=1;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<n;j++)cin >> niz[j];
        int l=0;
        int c = 0;
        while(niz[l]==0)
        {
            c+=res[l];
            res[l]=0;
            l++;
        }
        res[l]+=c;
        int r = n-1;
        c=0;
        while(niz[r]==0)
        {
            c+=res[r];
            res[r]=0;
            r--;
        }
        res[r]+=c;
        c=0;
        for(int j=l;j<=r;j++)
        {
            if(niz[j]==0)
            {
                int poc = j-1;
                while(niz[j]==0)
                {
                    c+=res[j];
                    res[j]=0;
                    j++;
                }
                int kraj = j;
                if(c%2==0)
                {
                    res[poc]+=c/2;
                    res[kraj]+=c/2;
                }
                else
                {
                    res[poc]+=(c-1)/2;
                    res[kraj]+=(c-1)/2;
                    if(i%2==0)res[poc]++;
                    else res[kraj]++;
                }
                c=0;
            }
        }
    }
    for(int i=0;i<n;i++)cout << res[i] << " ";
    return 0;
}