#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main ()
{
    ios_base::sync_with_stdio(false);
    int n, h, c, s, i; cin >> h >> n;
    vector<int> a(n,1), b(n);
    for(int r=1;r<=h;r++) {
        for(i=0;i<n;i++) cin >> b[i];
        c=0, s=0;
        for(i=0;i<n;i++) {
            if(b[i]==0) c++, s+=a[i], a[i]=0;
            else {
                if(i==c) a[i]+=s;
                else if(r&1) a[i]+=s/2, a[i-c-1]+=(s+1)/2;
                else a[i]+=(s+1)/2, a[i-c-1]+=s/2;
                s=c=0;
            }
        }
        if(b[n-1]==0) a[n-c-1]+=s;
    }
    for(int i=0;i<n;i++) cout << a[i] << " ";
    return 0;
}