#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, n;
    cin >> h >> n;
    bool a[h][n];
    int pom;
    vector<int> sledeciOk[h];
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < n; j++)
        {
            cin >> pom;
            if(pom == 0)
                a[i][j] = false;
            else
            {
                a[i][j] = true;
                sledeciOk[i].push_back(j);
            }
        }
        sledeciOk[i].push_back(-1);
    }
    int mat[h + 1][n];
    for(int i = 0; i < n; i++)
        mat[0][i] = 1;
    int zadnjiOk = -1;
    int sledeciOkk, index = 0;
    for(int i = 0; i < h; i++)
    {
        zadnjiOk = -1;
        index = 0;
        sledeciOkk = sledeciOk[i][index];
        for(int j = 0; j < n; j++)
        {
            if(j > sledeciOkk && sledeciOkk != -1)
            {
                sledeciOkk = sledeciOk[i][index + 1];
                index++;
            }
            if(a[i][j])
            {
                zadnjiOk = j;
            }
            else
            {
                if(zadnjiOk == -1)
                {

                    mat[i][sledeciOkk] += mat[i][j];
                    mat[i][j] = 0;
                }
                else
                {
                    //cout << mat[i][j] << "element ";
                    if((i + 1) % 2 == 1)
                    {
                        if(sledeciOkk == -1)
                        {
                            mat[i][zadnjiOk] += mat[i][j];
                            mat[i][j] = 0;
                        }
                        else
                        {
                            if(mat[i][j] % 2 == 1)
                            {
                                mat[i][zadnjiOk] += (mat[i][j] / 2 + 1);
                                mat[i][sledeciOkk] += mat[i][j] / 2;
                                mat[i][j] = 0;
                            }
                            else
                            {
                                mat[i][zadnjiOk] += mat[i][j] / 2;
                                mat[i][sledeciOkk] += mat[i][j] / 2;
                                mat[i][j] = 0;
                            }
                        }

                    }
                    else
                    {
                        if(sledeciOkk == -1)
                        {
                            mat[i][zadnjiOk] += mat[i][j];
                            mat[i][j] = 0;
                        }
                        else
                        {
                            if(mat[i][j] % 2 == 1)
                            {
                                mat[i][zadnjiOk] += mat[i][j] / 2;
                                mat[i][sledeciOkk] += mat[i][j] / 2 + 1;
                                mat[i][j] = 0;
                            }
                            else
                            {
                                mat[i][zadnjiOk] += mat[i][j] / 2;
                                mat[i][sledeciOkk] += mat[i][j] / 2;
                                mat[i][j] = 0;
                            }
                        }
                    }
                }
            }
        }
        for(int j = 0; j < n; j++)
            mat[i + 1][j] = mat[i][j];
    }
    /*for(int i = 0; i <= h; i++)
    {
        for(int j = 0; j < n; j++)
            cout << mat[i][j] << " ";
        cout << endl;
    }*/

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


    return 0;
}