#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //srand(time(NULL));

    int h,n; cin >> h >> n;

    //int **a = new int*[h];
    //vector <int> stene[h];

      int tok[n]; for (int i=0; i<n; i++) tok[i]=1;


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

       int a[n];
       vector <int> stene;


        for (int j=0; j<n; j++)
         {  cin >> a[j];  if (a[j]==0) stene.push_back(j); }

         //aa


            bool neparan=false;
            if ((i+1)%2==1) neparan=true;

            for (int j=0; j<stene.size(); j++)
            {
               int prvi=stene[j];
               int drugi = prvi;

               if (j<stene.size())
               while((stene[j+1]-stene[j])==1)
               {
                   if ((stene[j+1]-stene[j])==1) drugi = stene[j+1];
                   if ((stene[j+1]-stene[j])==1) j++;
                   if (j==stene.size()) break;
               }

                  if (prvi==0)
                 {
                     int zbir =0;
                     for (int i=0; i<=drugi; i++)
                     {
                         zbir+=tok[i];
                         tok[i]=0;
                     }
                     tok[drugi+1]+=zbir;
                 }

                 else
                  if (drugi==(n-1))
                 {
                     int zbir =0;
                     for (int i=n-1; i>=prvi; i--)
                     {
                         zbir+=tok[i];
                         tok[i]=0;
                     }
                     tok[prvi-1]+=zbir;
                 }

                else

                  {

                    int zbir =0;

                    for (int i=prvi; i<=drugi; i++)
                     {
                         zbir+=tok[i];
                         tok[i]=0;
                     }

                     int dod= zbir/2;

                     if ((zbir%2)==0)
                     {
                         tok[prvi-1]+=dod;
                         tok[drugi+1]+=dod;
                     }

                     if ((zbir%2)==1)
                     {
                         tok[prvi-1]+=dod;
                         tok[drugi+1]+=dod;

                         if (neparan) tok[prvi-1]++; else  tok[drugi+1]++;
                     }

                    }

            }

         }


















         for (int i=0; i<n; i++)
            cout << tok[i] << " ";

       /*
       for (int i = 0; i < h; i++)
         {
            delete[] a[i];  stene[i].clear();  }

       delete[] a;*/

}