#include <bits/stdc++.h>
using namespace std;
int voda[10000][10000] , maska[100000];

int checkb(int i,int j)
{

    for(int x = j-1; x > -1;x--)
    {
        if(voda[i] [x]==1)
            return x;

    }
return j +1;
}
int main()
{
int h ,m;
scanf("%d %d", &h, &m);

for(int i = 0; i < h; i++)
{

    for(int j = 0;j<m;j++){
        maska[j] = 1;
         scanf("%d", &voda[i] [j]);
    }


}



for(int i = 0; i < h; i++)
{
    for(int j = 0;j<m;j++)
{
     if(voda[i] [j] == 0)
     {
     if(j == m -1)
    {
        maska[checkb(i,j)]+= maska[j];
        maska[j] =0;
    }
    else if(j == 0)
    {
             maska[j+1] += maska[j];
        maska[j]=0;
    }
    else if(voda [i] [j+1] == 0)
    {
             maska[j+1] += maska[j];
        maska[j]=0;
    }




    else if(maska[j] % 2 == 0)
       {
            maska[j+1] += maska[j]/2;
           maska[checkb(i,j)] += maska[j] /2 ;
           maska[j] = 0;
       }
       else
       {
           if(i  % 2 == 0)
           {

               maska[j+1] += maska[j]/2;
            maska[checkb(i,j)] += maska[j] /2+1 ;
            maska[j] = 0;
           }
            else
            {
                    maska[j+1] += maska[j]/2+1;
                    maska[checkb(i,j)] += maska[j] /2;
                    maska[j] = 0;
            }

       }


     }


}

}

    for(int j = 0;j<m;j++)
{
    printf("%d ",maska[j]);
}

    return 0;
}