#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int h, n, br, leftIndex, rightIndex;
    cin >> h >> n;
    vector<vector<int> > v(h, vector<int>(n));
    vector<int> waves(n, 1);

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < n; j++)
            cin >> v[i][j];
    }

    for (int i = 0; i < h; i++)
    {
        leftIndex = -1;
        rightIndex = -1;

        for (int j = 0; j < n;)
        {
            br = 0;

            if (v[i][j] == 1)
            {
                leftIndex = j;
                j++;
                continue;
            }

            while (v[i][j] == 0 && j < n)
            {
                br += waves[j];
                waves[j] = 0;
                j++;
            }

            if (j != n)
            {
                rightIndex = j;
                if (leftIndex == -1)
                    waves[rightIndex] += br;

                else if (br % 2 == 0)
                {
                    waves[leftIndex] += br / 2;
                    waves[rightIndex] += br / 2;
                }

                else
                {
                    if (((i + 1) % 2) == 0)
                    {
                        waves[leftIndex] += br / 2;
                        waves[rightIndex] += br / 2 + 1;
                    }

                    else
                    {
                        waves[leftIndex] += br / 2 + 1;
                        waves[rightIndex] += br / 2;
                    }
                }
             }

             else
                waves[leftIndex] += br;
        }
    }

    for (int i = 0; i < waves.size(); i++)
        cout << waves[i] << " ";

    return 0;
}