#include <iostream>
using namespace std;

int tok[1000001];

int main()
{
    int n, h;
    cin >> h >> n;
    for (int i = 0; i < n; i++)
        tok[i] = 1;
    bool** mat;
    mat = new bool*[h];
    for (int i = 0; i < h; i++)
        mat[i] = new bool[n];
    for (int i = 0; i < h; i++)
        for (int j = 0; j < n; j++)
            cin >> mat[i][j];
    for (int i = 0; i < h; i++)
        for (int j = 0; j < n; j++) {
            if (!mat[i][j]) {
                int zbir = 0;
                int l = j - 1;
                while (!mat[i][j] && j < n) {
                    zbir += tok[j];
                    tok[j] = 0;
                    j++;
                }
                j--;
                if (j == n - 1) {
                    tok[l] += zbir;
                    continue;
                }
                if (l == -1) {
                    tok[j + 1] += zbir;
                    continue;
                }
                if (zbir % 2 == 1) {
                    zbir -= 1;
                    if ((i + 1) % 2 == 0)
                        tok[j + 1] += 1;
                    else
                        tok[l] += 1;
                }
                tok[l] += (zbir / 2);
                tok[j + 1] += (zbir / 2);

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

    return 0;
}