#include <iostream>
#include <vector>

int main()
{
    unsigned long long h, n;
    std::cin >> h >> n;

    std::vector<std::vector<unsigned long long>> schema;
    std::vector<std::vector<unsigned long long>> m;

    schema.reserve(h + 1);
    m.reserve(h + 1);
    for (unsigned long long i = 1; i <= h; i++)
    {
        schema[i].reserve(n + 1);
        m[i].reserve(n + 1);
        for (unsigned long long j = 1; j <= n; j++)
        {
            std::cin >> schema[i][j];
        }
    }

    for (unsigned long long i = 1; i <= h; i++)
    {
        for (unsigned long long j = 1; j <= n; j++)
        {
            unsigned long long src = (i == 1 ? 1 : m[i - 1][j]);
            if (src > 0)
            {
                if (schema[i][j] == 0)
                {
                    m[i][j] = 0;
                    unsigned long long left = 0, right = 0;

                    if (j != 1 && j != n)
                    {
                        left = src / 2;
                        right = left;
                        if ((left + right) != src)
                        {
                            if (i % 2 != 0)
                            {
                                left++;
                            } else
                            {
                                right++;
                            }
                        }
                    } else {

                        if (j == 1)
                        {
                            right = src;
                        } else {
                            left = src;
                        }
                    }

                    bool isLeft = true;
                    unsigned long long lDrop = j;

                    for (int p = 0; p < 2; p++)
                    {
                        unsigned long long val = (isLeft ? left : right);
                        if (val == 0)
                        {
                            isLeft = false;
                            continue;
                        }

                        unsigned long long drop = j;
                        while (schema[i][drop] == 0)
                        {
                            drop += (isLeft ? -1 : 1);

                            if (drop < 1)
                            {
                                right += left;
                            } else if (drop > n)
                            {
                                m[i][lDrop] += val;
                            }
                        }
                        m[i][drop] += val;

                        if (isLeft)
                        {
                            lDrop = drop;
                        }

                        isLeft = false;
                    }
                } else {
                    m[i][j] += src;
                }
            }
        }
    }

    for (unsigned long long j = 1; j <= n; j++)
    {
        std::cout << m[h][j] << (j != n ? " ": "");
    }

    return 0;
}