#include <iostream>
#include <vector>
using namespace std;

bool ok(vector<int> waterflow, vector<int> vodopad) {
    bool ok = true;
    for (int i = 0; i<vodopad.size(); i++) {
        if (waterflow[i] != 0 && vodopad[i] == 0) {
                //cout << "not ok vise, waterflow[" << i<<"] je " << waterflow[i] << " a vodopad[" << i<< "] je " << vodopad[i] <<endl;
            ok = false;
            break;
        }
    }
    //cout << "ok?: " << to_string(ok) << endl;
    return ok;
}

int main()
{
    int h,n;
    cin >> h >> n;
    vector<vector<int>> vodopad;
    for (int i = 0; i<h; i++) {
        vector<int> vodopadic;
        for (int g = 0; g<n; g++) {
            int a;
            cin >> a;
            vodopadic.push_back(a);
        }
        vodopad.push_back(vodopadic);
    }
    vector<int> waterflow;
    for (int i = 0; i<n; i++) {
        waterflow.push_back(1);
    }
    int red = 0;
    while (red < h) {
        while (!ok(waterflow,vodopad[red])) {
            for (int i = 0; i<n; i++) {
                if (vodopad[red][i] == 0) {
                    //cout << "polje " << red << " " << i << " je stenasto" <<endl;
                    if (i == 0) {
                            //cout << "resavamo polje 0" << endl;
                        waterflow[1] += waterflow[0];
                        waterflow[0] = 0;
                    } else if (i == n-1) {
                        //cout << "resavamo polje poslednje, " << i << endl;
                        waterflow[n-2] += waterflow[n-1];
                        waterflow[n-1] = 0;
                    } else {
                        int gg = i;
                        for (int g = i; g<n; g++) {
                            if (vodopad[red][g] == 1 || g==n-1) {
                                gg = g-1;
                                if (g==n-1 && !((vodopad[red][g] ==1 ))) {gg++;}
                                //cout << "g je " << g << endl;
                                break;
                            }
                        }
                        //cout << "resavamo polje " << i << endl;
                        int flow = 0;
                        //cout << "i je "  << i << ", a gg je " << gg << endl;
                        for (int m = i; m <=gg; m++) {
                                //cout << "dodajemo flow" << endl;
                            flow+= waterflow[m];
                        }
                        //int flow = waterflow[i];
                        int levo = flow/2;
                        int desno = flow/2;
                        if (flow % 2 != 0) {
                            if (red % 2 !=0) {
                                desno++;
                            } else {
                                levo++;
                            }
                        }
                        //cout << "flow je " << flow << endl;
                        if (gg==n-1) {
                            levo+=desno;
                            desno = 0;
                        } else if (i==0) {
                                   desno+=levo;
                                   levo = 0;
                                   }
                        //cout << "polje " << to_string(i-1) << ": " << waterflow[i-1] << endl;;
                        //cout << "polje " << to_string(i) << ": " << waterflow[i] << endl;;
                        //cout << "polje " << to_string(gg+1) << ": " << waterflow[gg+1] << endl;

                        //cout << "desno ide " << desno << endl;
                        //cout << "levo ide " << levo << endl;

                        for (int m = i; m<=gg; m++) {
                            waterflow[m] = 0;
                        }
                        //waterflow[i] = 0;
                        waterflow[i-1] += levo;
                        waterflow[gg+1] += desno;

                        //cout << "polje " << to_string(i-1) << ": " << waterflow[i-1] << endl;;
                        //cout << "polje " << to_string(i) << ": " << waterflow[i] << endl;;
                        //cout << "polje " << to_string(gg+1) << ": " << waterflow[gg+1] << endl;


                    }
                }
            }
            //for (int i = 0; i<n;i++) {
            //cout << to_string(waterflow[i]) << " ";
            //}
            //cout << "=====nibba=====" << endl;
        }
        //for (int i = 0; i<n;i++) {
        //    cout << to_string(waterflow[i]) << " ";
        //}
        //cout << "=========================BIG NIGGA==========================" << endl;
        red++;
    }
    for (int i = 0; i<n;i++) {
        cout << to_string(waterflow[i]) << " ";
    }
    cout << endl;
    return 0;
}