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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int i, j, h, n, l, d, suma;

    cin >> h >> n;

    vector<int> a(n, 1), b(n);

    for(i = 1; i <= h; ++i)
    {
        for(j = 0; j < n; ++j) cin >> b[j];
        j = 0;
        if(b[j] == 0)
        {
            suma = 0;
            while(b[j] == 0)
            {
                suma += a[j];
                a[j] = 0;
                ++j;
            }
            a[j] += suma;
        }
        while(j < n)
        {
            if(b[j] == 0)
            {
                l = j - 1;
                suma = 0;
                while(b[j] == 0 && j < n)
                {
                    suma += a[j];
                    a[j] = 0;
                    ++j;
                }
                d = j;
                if(d == n) a[l] += suma;
                else
                {
                    a[l] += suma / 2;
                    a[d] += suma / 2;
                    if(suma % 2 != 0)
                    {
                        if(i % 2 != 0) a[l]++;
                        else a[d]++;
                    }
                }
            }
            ++j;
        }
    }

    for(int x = 0; x < n; ++x) cout << a[x] << " ";

    cout << endl;

    return 0;
}