#include <iostream>

int main()
{
    int visina;
    int sirina;

    std::cin >> visina;
    std::cin >> sirina;

    int **matrica = new int*[visina];
    for(int i = 0; i < visina; i ++)
    {
        matrica[i] = new int[sirina];
    }

    int* stari_tok = new int[sirina];
    int* novi_tok = new int[sirina];
    for(int i = 0; i < sirina; i ++)
    {
        novi_tok[i] = 1;
    }


    for(int i = 0; i < visina; i ++)
    {
        for(int j = 0; j< sirina; j++)
        {
            std::cin >> matrica[i][j];
        }
    }

    std::cout << "\n";

    for(int i = 0; i < visina; i ++)
    {
        for(int j = 0; j < sirina; j++)
        {
            stari_tok[j] = novi_tok[j];
            novi_tok[j] = 0;
        }

        int startStena = -1, endStena = -1;

        for(int j = 0; j< sirina; j++)
        {
            if(matrica[i][j] == 1) novi_tok[j] += stari_tok[j];

           if (startStena == -1 && matrica[i][j] == 0)
           {
                startStena = j;
                if(j == sirina - 1) endStena == j;
           }
           if(startStena != -1 && (matrica[i][j] == 1 || j == sirina -1))
           {
               if(matrica[i][j] == 1)endStena = j-1;
               else if(j == sirina-1)endStena = j;

               int zbirPrenosa = 0;
               for(int k = startStena; k <= endStena; k++)
               {
                   zbirPrenosa+=stari_tok[k];
               }

               if(startStena == 0)
               {

                   novi_tok[endStena + 1] += zbirPrenosa;
                   startStena = -1; endStena = -1;
               }
               else if(endStena == sirina - 1)
               {

                   novi_tok[startStena - 1] +=zbirPrenosa;
                   startStena = -1; endStena = -1;
               }
               else
               {
                   novi_tok[startStena-1] += zbirPrenosa/2;
                   novi_tok[endStena + 1] += zbirPrenosa/2;


                   if((i+1)%2 == 1) novi_tok[startStena - 1] += zbirPrenosa%2;
                   else novi_tok[endStena + 1] += zbirPrenosa%2;
                   startStena = -1; endStena = -1;
               }
           }

        }


    }

for(int l = 0; l < sirina; l++)
            {
                std::cout << novi_tok[l] << " ";
            }



    for(int i = 0; i < visina; i ++)
    {
        delete[] matrica[i];
    }
    delete[] matrica;
    delete[] stari_tok;
    delete[] novi_tok;
    return 0;
}
#include <iostream>

int main()
{
    int visina;
    int sirina;

    std::cin >> visina;
    std::cin >> sirina;

    int **matrica = new int*[visina];
    for(int i = 0; i < visina; i ++)
    {
        matrica[i] = new int[sirina];
    }

    int* stari_tok = new int[sirina];
    int* novi_tok = new int[sirina];
    for(int i = 0; i < sirina; i ++)
    {
        novi_tok[i] = 1;
    }


    for(int i = 0; i < visina; i ++)
    {
        for(int j = 0; j< sirina; j++)
        {
            std::cin >> matrica[i][j];
        }
    }

    std::cout << "\n";

    for(int i = 0; i < visina; i ++)
    {
        for(int j = 0; j < sirina; j++)
        {
            stari_tok[j] = novi_tok[j];
            novi_tok[j] = 0;
        }

        int startStena = -1, endStena = -1;

        for(int j = 0; j< sirina; j++)
        {
            if(matrica[i][j] == 1) novi_tok[j] += stari_tok[j];

           if (startStena == -1 && matrica[i][j] == 0)
           {
                startStena = j;
                if(j == sirina - 1) endStena == j;
           }
           if(startStena != -1 && (matrica[i][j] == 1 || j == sirina -1))
           {
               if(matrica[i][j] == 1)endStena = j-1;
               else if(j == sirina-1)endStena = j;

               int zbirPrenosa = 0;
               for(int k = startStena; k <= endStena; k++)
               {
                   zbirPrenosa+=stari_tok[k];
               }

               if(startStena == 0)
               {

                   novi_tok[endStena + 1] += zbirPrenosa;
                   startStena = -1; endStena = -1;
               }
               else if(endStena == sirina - 1)
               {

                   novi_tok[startStena - 1] +=zbirPrenosa;
                   startStena = -1; endStena = -1;
               }
               else
               {
                   novi_tok[startStena-1] += zbirPrenosa/2;
                   novi_tok[endStena + 1] += zbirPrenosa/2;


                   if((i+1)%2 == 1) novi_tok[startStena - 1] += zbirPrenosa%2;
                   else novi_tok[endStena + 1] += zbirPrenosa%2;
                   startStena = -1; endStena = -1;
               }
           }

        }


    }

for(int l = 0; l < sirina; l++)
            {
                std::cout << novi_tok[l] << " ";
            }



    for(int i = 0; i < visina; i ++)
    {
        delete[] matrica[i];
    }
    delete[] matrica;
    delete[] stari_tok;
    delete[] novi_tok;
    return 0;
}