#include<bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;

struct struk
{
    int x, l, d;
};


int t1[1000010];
int t2[1000010];
struk polje[1000010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n >> m;

    for(int i = 1; i <= m; i++) t1[i] = 1, t2[i] = 0;

    for(int i = 1; i <= n; i++)
    {
        int p = -1;
        for(int j = 1; j <= m; j++)
        {
            cin >> polje[j].x;
            if(polje[j].x == 0) polje[j].l = p;
            else p = j, polje[j].l = 0;
            //if(i == 2 && j == 1) cout << "*** " << p << " " << polje[j].d << " ****\n";
        }
        p = -1;
        for(int j = m; j > 0; j--)
        {
            if(polje[j].x == 0) polje[j].d = p;
            else p = j, polje[j].d = 0;
        }

        for(int j = 1; j <= m; j++)
        {
            if(t1[j] > 0)
            {
                if(polje[j].x > 0) t2[j] += t1[j];// ako nije stena
                else
                {
                    //t2[j] = 0;
                    int levo = polje[j].l;
                    int desno = polje[j].d;
                    if(levo == -1) t2[desno] += t1[j];
                    else if(desno == -1) t2[levo] += t1[j];
                    else
                    {
                        t2[levo] += t1[j]/2;
                        t2[desno] += t1[j]/2;
                        if(t1[j] % 2 != 0)
                            if(i % 2 == 0) t2[desno]++;
                            else t2[levo]++;
                    }
                }
            }
        }
        //update
        for(int j = 1; j <= m; j++) t1[j] = t2[j], t2[j] = 0;
        /*cout << "protoci \n";
        for(int i = 1; i <= m; i++) cout << t1[i] << " ";
        cout << "\n levi \n";
        for(int i = 1; i <= m; i++) cout << polje[i].l << " ";
        cout << "\n desni \n";
        for(int i = 1; i <= m; i++) cout << polje[i].d << " ";
        cout << "\n";*/
    }

    for(int i = 1; i <= m; i++) cout << t1[i] << " ";

    return 0;
}