#include <bits/stdc++.h>

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define nul(x) memset((x),0,sizeof((x)))
#define random_jbt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

int n,m;
vector<int>v[1000100];
int d[1000100];
int ans[1000100];

int main(){
    ios;


    cin>>n>>m;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            int x;cin>>x;
            v[i].pb(x);
        }
    }
    for (int i=0;i<m;i++)d[i]=1;

    for (int i=1;i<=n;i++){
        //rad s vodopadima
        for (int j=0;j<m;j++){
            int sum = 0, pam = j-1;
            while (v[i][j]==0){
                sum += d[j];
                d[j]=0;
                j++;
                if (j==m)break;
            }

            if (sum > 0 ){
            	//cout<<"prebacujem: "<<sum<<" "<<pam<<" "<<j<<"\n";
                if (pam>=0 and j<m){
                    //normalna raspodela
                    d[pam] += sum/2;
                    d[j] += sum/2;
                    if (sum%2==1){
                        if (i%2==1)d[pam]++;
                        else d[j]++;
                    }
                }
                else if (pam>=0)d[pam] += sum;
                else d[j] += sum;
            }
        }

        //for (int j=0;j<m;j++)cout<<d[j]<<" ";cout<<"\n";
    }

    for (int j=0;j<m;j++)cout<<d[j]<<" ";
    return 0;
}