#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

auto main() -> int
{
    int red=0, h, n; cin >> h >> n;
    vector<int> flow;
    for(int i=0; i<n; i++) flow.push_back(1);
    while(red < h)
    {
        auto l=flow.begin()-1, r=flow.begin();
        for(; r<=flow.end(); r++)
        {
            int x=1; if(r!=flow.end()) cin >> x; if(x)
            {
                int s = accumulate(l+1, r, 0);
                fill(l+1, r, 0);
                if(r==flow.end())     *l += s; else
                if(l+1==flow.begin()) *r += s; else
                {
                    int incR = (s%2) ? (s/2 + red%2):(s/2);
                    *l += s - incR;
                    *r += incR;
                } l=r;
            }
        }
        red++;
    }
    for(int i=0; i<n; i++) cout << flow[i] << " ";
}