#include<iostream>
using namespace std;

int STENA = 0;

int Preusmeri(int protok[], int indeksreda, int red[], int duzina)
{
    for (int i = 0; i < duzina; i++)
    {
        if (protok[i] == 0)
        {
            continue;
        }
        if (red[i] != STENA)
        {
            continue;
        }
        int indexLeft = -1;
        for (int l = i-1; l >= 0; l--)
        {
            if (red[l] != STENA)
            {
                indexLeft = l;
                break;
            }
        }
        int indexRight = -1;
        for (int d = i + 1; d < duzina; d++)
        {
            if (red[d] != STENA)
            {
                indexRight = d;
                break;
            }
        }
        if (indexLeft >= 0 && indexRight >= 0)
        {
            int polovinaToka = protok[i] / 2;
            protok[indexLeft] += polovinaToka;
            protok[indexRight] += polovinaToka;

            int ostatak = protok[i] % 2;
            if (ostatak > 0)
            {
                if (indeksreda % 2 == 0)
                {
                    protok[indexRight] += ostatak;
                }
                else
                {
                    protok[indexLeft] += ostatak;
                }
            }
        }
        else if (indexLeft >= 0)
        {
            protok[indexLeft] += protok[i];
        }
        else
        {
            protok[indexRight] += protok[i];
        }
        protok[i] = 0;
    }
}

int main()
{
    int h;
    int n;
    cin>>h>>n;
    int protok[n];
    for (int i=0; i<n; i++)
    {
        protok[i] = 1;
    }
    int indeksReda = 1;
    while (indeksReda <= h)
    {
        int red[n];
        int ulaz;
        for (int i=0; i<n; i++)
        {
            cin>>ulaz;
            red[i] = ulaz;
        }

        Preusmeri(protok, indeksReda, red, n);
        indeksReda++;
    }
    for (int i=0; i<n; i++)
    {
        cout<<protok[i]<<" ";
    }
    return 0;
}