#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
int n,m;
cin >>n>>m;
vector <int> vi(m);
vector <vector <int> > a(n,vi);
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        cin >>a[i][j];
    }
}

vector <int> Flow(m,1);
vector <int> Next(m,0);
for(int i=0;i<n;i++){
        int j=0;
    while(j<m){
    if(a[i][j]==1){Next[j]+=Flow[j];j++;continue;}
        int index=j;
        int sum=0;

        while(index<m&&a[i][index]==0){
            sum+=Flow[index];
            index++;
        }
        if(j==0){
            Next[index]+=sum;
        }
        else if(index==m){
            Next[j-1]+=sum;
        }
        else{
            int rem=sum%2;
            sum-=rem;

            Next[j-1]+=sum/2;
            Next[index]+=sum/2;

            if(i%2==0)Next[j-1]+=rem;
            else Next[index]+=rem;
        }

    j=index;
    }
    Flow=Next;

    for(int j=0;j<m;j++)Next[j]=0;
}
for(int i=0;i<m;i++){
    cout <<Flow[i]<<" ";
}
cout <<endl;

}