#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    int waterfall[h+1][n+1];
    int waterfall_current[h+1][n+1];
    for(int i=1; i <= h; ++i)
    {
        for(int j=1; j <= n; ++j)
        {
            cin >> waterfall[i][j];
            waterfall_current[i][j] = waterfall[i][j];
            if(i > 1)
            {
                if(waterfall[i-1][j] == 0 || waterfall_current[i-1][j] == 0)
                {
                    waterfall_current[i][j] = 0;
                }
            }
        }
    }

    for(int i=1; i <= h; ++i)
    {
        if(i > 1){
            for(int j=1; j <= n; ++j)
            {
                if(waterfall[i][j] != 0)
                {
                    waterfall_current[i][j] = waterfall_current[i-1][j];
                }
            }
        }

        if(waterfall[i][1] == 0)
        {
            int wfv = 0;
            int jj = 1;
            while(jj <= n)
            {
                if(waterfall[i][jj] == 0)
                {
                    if(i == 1)
                    {
                        wfv++;
                    }
                    else
                    {
                        wfv += waterfall_current[i-1][jj];
                    }
                    waterfall[i][jj] = -1;
                }
                else
                {
                    break;
                }
                ++jj;
            }
            waterfall_current[i][jj] += wfv;
        }

        if(waterfall[i][n] == 0)
        {
            int wfv = 0;
            int jj = n;
            while(jj >= 1)
            {
                if(waterfall[i][jj] == 0)
                {
                    if(i == 1)
                    {
                        wfv++;
                    }
                    else
                    {
                        wfv += waterfall_current[i-1][jj];
                    }
                    waterfall[i][jj] = -1;
                }
                else
                {
                    break;
                }
                --jj;
            }
            waterfall_current[i][jj] += wfv;
        }

        for (int j = 2; j < n; ++j)
        {
            if(waterfall[i][j] == 0)
            {
                int wfv = 0;
                int jj = j;
                if(i > 1)
                {
                    while(jj < n)
                    {
                        if(waterfall[i][jj] == 0)
                        {
                            wfv += waterfall_current[i-1][jj];
                            waterfall[i][jj] = -1;
                        }
                        else
                        {
                            break;
                        }
                        ++jj;
                    }
                }
                else
                {
                    while(jj < n)
                    {
                        if(waterfall[i][jj] == 0)
                        {
                            wfv++;
                            waterfall[i][jj] = -1;
                        }
                        else
                        {
                            break;
                        }
                        ++jj;
                    }
                }

                if(wfv % 2 == 0)
                {
                    waterfall_current[i][j-1] += wfv/2;
                    waterfall_current[i][jj] += wfv/2;
                }
                else
                {
                    if(i % 2 == 0)
                    {
                        waterfall_current[i][j-1] += wfv/2;
                        waterfall_current[i][jj] += wfv/2 + 1;
                    }
                    else
                    {
                        waterfall_current[i][j-1] += wfv/2 + 1;
                        waterfall_current[i][jj] += wfv/2;
                    }
                }
            }
        }
    }

    for(int j = 1; j <=n ++j)
    {
        cout << waterfall_current[h][j] << " "; 
    }

    return 0;
}