#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

void display(int m[], int n)
{
    for (int i = 0; i < n; ++i)
    {
        printf("%d ",m[i]);
    }
    printf("\n");
}
int main()
{
    cin.tie(0);
    int h, n, i , j;
    scanf("%d %d", &h, &n);
    bool matrica[h][n];
    int resenje[n];
    for(i=0;i<h;i++)
        for(j=0;j<n;j++)
    {
        cin >> matrica[i][j];
        resenje[j] = 1;
    }
    int levo= 1, pom = 0;

    for(i=0;i<h;i++)
        for(j=0;j<n;j++){
        if(matrica[i][j]==0)
        {
            levo =1;
            pom = resenje[j];
            resenje[j]=0;
            if(j+1 !=n)
                while(matrica[i][j+1]==0){
                    levo++;
                    j++;
                    pom += resenje[j];
                    resenje[j]=0;
                    if(j+1 == n)
                        break;
                }
            if(levo == j+1)
            {
                resenje[j+1] +=pom;
            }
            else
            if(j+1 == n)
            {
                resenje[j-levo]+=pom;
            }
            else{
            switch(pom%2){
                case 1: if((i+1)%2 ==0) {resenje[j-levo] += pom/2; resenje[j+1] += pom/2+1;} else  {resenje[j-levo] += pom/2+1; resenje[j+1] += pom/2;} break;
                case 0:  resenje[j-levo] += pom/2;   resenje[j+1] += pom/2; break;

            }
            }
        }
    }
    display(resenje,n);
}