#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1000005;
ll a[maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    for(ll i=1;i<=m;i++)a[i]=1;
    for(ll i=n;i>=1;i--){
        bool pom=true;
        ll l,brojac=0;
        for(ll j=1;j<=m;j++){
            int x;
            cin >> x;
            if(x == 0){
                brojac+=a[j];
                if(pom){
                    l=j;
                    pom=false;
                }
                a[j]=0;
            }
            else{
                if(brojac == 0)continue;
                pom=true;
                if(l == 1)a[j]+=brojac;
                else{
                    if(brojac%2 == 0){
                        a[l-1]+=brojac/2;
                        a[j]+=brojac/2;
                    }
                    else{
                        brojac--;
                        if(i%2 == 1){
                            a[l-1]+=brojac/2+1;
                            a[j]+=brojac/2;
                        }
                        else{
                            a[l-1]+=brojac/2;
                            a[j]+=brojac/2+1;
                        }

                    }
                }

                brojac=0;
            }
        }
        if(brojac != 0)a[l-1]+=brojac;
        /*for(int i=1;i<=m;i++)cout << a[i] << " ";
        cout << endl;*/
    }
    for(ll i=1;i<=m;i++)cout << a[i] << " ";
    cout << endl;
    return 0;
}