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

const int N=100001;
int red[N];
int lev[N];
int des[N];
int tok[N][2];
int h,n;
bool par=true;

void print(int a[],int len, string str){
    cout<<str<<" ";for(int i=0;i!=len;i++)cout<<a[i]<<" ";cout<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>h>>n;
    for(int i=0;i!=n;i++)tok[i][h%2]=1;
    while(h--){
        par=!par;
        for(int i=0;i!=n;i++){
            cin>>red[i];
            tok[i][h%2]=0;
        }
        //print(red,n,"red");
        for(int i=0;i!=n;i++){
            if(i==0)lev[i]=(red[i])?i:-1;
            else lev[i]=(red[i])?i:lev[i-1];
        }
        //print(lev,n,"lev");
        for(int i=n-1;i>=0;i--){
            if(i==n-1)des[i]=(red[i])?i:-1;
            else des[i]=(red[i])?i:des[i+1];
        }
        //print(des,n,"des");
        for(int i=0;i!=n;i++){
            if(lev[i]==des[i]){
                tok[i][h%2]+=tok[i][(h+1)%2];
            }
            else{
                if(lev[i]==-1) tok[des[i]][h%2] += tok[i][(h+1)%2];
                else if(des[i]==-1) tok[lev[i]][h%2] += tok[i][(h+1)%2];
                else{
                    tok[lev[i]][h%2] += tok[i][(h+1)%2]/2;
                    tok[des[i]][h%2] += tok[i][(h+1)%2]/2;
                    if(tok[i][(h+1)%2]%2){
                        if(!par && lev[i]!=-1) tok[lev[i]][h%2]++;
                        else if(!par && lev[i]==-1) tok[des[i]][h%2]++;
                        else if(par && des[i]!=-1) tok[des[i]][h%2]++;
                        else if(par && des[i]==-1) tok[lev[i]][h%2]++;
                    }
                }
            }
        }
        //cout<<"TOK ";for(int i=0;i<n;i++)cout<<tok[i][h%2]<<" ";cout<<endl;
    }
    for(int i=0;i<n;i++)cout<<tok[i][(h+1)%2]<<" ";cout<<endl;
    return 0;
}