#include <bits/stdc++.h>
using namespace std;
int protok[1000005], stena[1000005], redispod[1000005];
int main()
{
    long long h, n, i, j, s = 0, l = 0;
    cin >> h >> n;
    stena[0] = 1;
    stena[n + 1] = 1;
    for(i = 1; i <= n; i++) protok[i] = 1;
    for(j = 1; j <= h; j++)
    {
        for(i = 1; i <= n; i++) cin >> stena[i];
        i = 1; s = 0; l = 0;
        while(i <= n + 1)
        {
            if(stena[i] == 0)
            {
                s = s + protok[i];
                redispod[i] = 0;
            }
            else
            {
                if(l == 0) redispod[i] = redispod[i] + s;
                else if(i == n + 1) redispod[l] = redispod[l] + s;
                else
                {
                    redispod[i] = redispod[i] + s/2 + (1 - (j%2))*(s%2);
                    redispod[l] = redispod[l] + s/2 + (j%2)*(s%2);
                }
                redispod[i] = redispod[i] + protok[i];
                s = 0;
                l = i;
            }
            i++;
        }

        for(i = 0; i <= n + 1; i++)
        {
            protok[i] = redispod[i];
            redispod[i] = 0;
        }
    }
    for(i = 1; i <= n; i++) cout << protok[i] << " ";
    return 0;
}