#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int D = 1e6+45;

int n,m;
int a[D],protok[D],novi[D];
int levo[D],desno[D];

inline int daj(int i,int j){
    return a[(i-1)*m+j];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[(i-1)*m+j];
        }
    }
    for(int i = 1; i <= n; i++){
        int posl = 0;
        for(int j = 1; j <= m; j++){
            if(daj(i,j)){
                posl = j;
            }
            levo[(i-1)*m+j] = posl;
        }
        posl = 0;
        for(int j = m; j >= 1; j--){
            if(daj(i,j)){
                posl = j;
            }
            desno[(i-1)*m+j] = posl;
        }
    }
    for(int j = 1; j <= m; j++){
        protok[j] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(daj(i,j)){
                novi[j] = protok[j];
            }
        }
        for(int j = 1; j <= m; j++){
            if(daj(i,j)){
                continue;
            }
            /// pada na kamen
            int l = levo[(i-1)*m+j],r = desno[(i-1)*m+j];
            if(!l){
                novi[r] += protok[j];
                novi[j] = 0;
                continue;
            }
            if(!r){
                novi[l] += protok[j];
                novi[j] = 0;
                continue;
            }
            if(protok[j]%2 == 0){
                novi[l] += protok[j]/2;
                novi[r] += protok[j]/2;
            }
            else{
                if(i%2 == 1){ /// idu levo
                    novi[l] += (protok[j]+1)/2;
                    novi[r] += protok[j]/2;
                }
                else{ /// idu desno
                    novi[l] += protok[j]/2;
                    novi[r] += (protok[j]+1)/2;
                }
            }
            novi[j] = 0;
        }
        for(int j = 1; j <= m; j++){
            protok[j] = novi[j];
        }
    }
    for(int j = 1; j <= m; j++){
        cout << protok[j] << " ";
    }
    cout << endl;
}