#include <bits/stdc++.h>

using namespace std;
int mat[1007][1007];

void solution(int h, int n)
{
    int hold_pointer, total_above = 0;
    bool brk_loop = false;
    int fat[h][n];
    for (int i = 0; i < h; i++)
        for (int j = 0; j < n; j++)
            fat[i][j] = 0;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (j == 0)
            {
                brk_loop = false;
                total_above = 0;
                hold_pointer = 0;
                while (mat[i][hold_pointer] == 0)
                {
                    if (i)
                        total_above += fat[i-1][hold_pointer];
                    else
                        total_above += 1;
                    hold_pointer += 1;
                    if (mat[i][hold_pointer] == 1)
                    {
                        fat[i][hold_pointer] += total_above;
                        j = hold_pointer-1;
                        brk_loop = true;
                    }
                }
                if (brk_loop)
                    continue;
            }
            if (mat[i][j] == 1)
            {
                if (i)
                    fat[i][j] += fat[i-1][j];
                else
                    fat[i][j] += 1;
                total_above = 0;
                if (j+1 < n)
                    hold_pointer = j+1;
                else continue;
                if (mat[i][j+1] != 0)
                    continue;
                while (mat[i][hold_pointer] == 0 && hold_pointer < n)
                {
                    if (i)
                        total_above += fat[i-1][hold_pointer];
                    else
                        total_above += 1;
                    hold_pointer++;
                }
                if (hold_pointer != n)
                {
                        if ((i+1) % 2 == 0) {
                            fat[i][hold_pointer] += total_above/2 + total_above % 2;
                            fat[i][j] += total_above/2;
                        }
                        else {
                            fat[i][hold_pointer] += total_above/2;
                            fat[i][j] += total_above/2 + total_above%2;
                        }
                        j = hold_pointer-1;
                } else {
                    fat[i][j] += total_above;
                    break;
                }

            }

        }
    }
    for (int i = 0; i < n; i++)
    {
        if (mat[h-1][i] == 0)
            cout << 0 << " ";
        else
            cout << fat[h-1][i] << " ";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int h, n;
    cin >> h >> n;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < n; j++)
            cin >> mat[i][j];
    solution(h, n);

    return 0;
}