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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, n, i, j, p, zbir;
    cin >> h >> n;
    bool matrica[h][n];
    for(i = 0; i < h; i++){
        for(j = 0; j < n; ++j){
            cin >> matrica[i][j];
        }
    }
    int niz[n];
    for(i = 0; i < n; ++i){
        niz[i] = 1;
    }
    for(i = 0, p = -1; i < h; i++, p = -1){
        for(j = 0; j < n; j++){
            if(j > 0 && !matrica[i][j]){
                p = j - 1;
            }
            zbir = 0;
            while(j < n && !matrica[i][j]){
                zbir += niz[j];
                niz[j] = 0;
                j++;
            }
            if(p == -1){
                niz[j] += zbir;
            }
            if(j == n){
                niz[p] += zbir;
            }
            else if(p != -1){
                if(zbir % 2 == 1){
                    if(i % 2 == 0){
                        niz[p]++;
                    }
                    else{
                        niz[j]++;
                    }
                    zbir--;
                }
                niz[p] += zbir / 2;
                niz[j] += zbir / 2;
            }
        }
    }
    for(i = 0; i < n; ++i){
        cout << niz[i] << " ";
    }
    return 0;
}