#include <iostream>
#include <algorithm>

using namespace std;

int a[1000000];

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout .tie(0);

    long long int n, h;

    cin >> h >> n;
    fill_n( a, n, 1 );

    int s, p;
    bool t, tp=1;
    for( int i = 0; i < h; i++ )
    {
        s = 0;
        for( int j = 0; j < n; j++ )
        {
            cin >> t;
            if(!t)
            {
                if(tp)
                    p = j;
                s += a[j];
                a[j] = 0;
            }
            else if(t && !tp)
            {
                if( p == 0 )
                    a[j] += s;
                else
                {
                    a[p-1] += s/2;
                    a[j] += s/2;
                    if( s%2 )
                    {
                        if( (i+1)%2 )
                            a[p-1]++;
                        else
                            a[j]++;
                    }
                }
                s = 0;
            }
            if( j == n-1 && !t )
                a[p-1] += s;
            tp = t;
        }
        tp=1;

    }

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

    return 0;
}