#include <bits/stdc++.h>

using namespace std;

static void autizam(vector<int> &stene, vector<int> &protok, int n, bool paran){
    vector<int> novost(n, 0);
    int leva_granica = -1;
    int zbir = 0;

    for(int i = 0; i < n; i++){
        if(stene[i] != -1){
            if(protok[i] > 0)
                novost[i] += protok[i];
            if(leva_granica < 0){
                novost[i] += zbir;
            }
            else{
                if(zbir % 2 == 0){
                    novost[i] += zbir / 2;
                    novost[leva_granica] += zbir / 2;
                }
                else{
                    if(!paran){
                        novost[leva_granica] += zbir / 2 + 1;
                        novost[i] += zbir / 2;
                    }
                    else{
                        novost[i] += zbir / 2 + 1;
                        novost[leva_granica] += zbir / 2;
                    }
                }
            }
            leva_granica = i;
            zbir = 0;
            }
        else if(protok[i] > 0){
            zbir += protok[i];
        }
    }

    if(zbir > 0)
            novost[leva_granica] += zbir;
    protok = novost;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h, n;
    cin >> h >> n;

    vector<vector<int>> vodopad (h, vector<int>(n));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < n; j++){
            int k;
            cin >> k;
            vodopad[i][j] = k - 1;
        }
    }
    vector<int> protok(n, 1);
    for(int i = 0; i < h; i++){
        autizam(vodopad[i], protok, n, i % 2 == 1);
        /*for(int i = 0; i < n; i++){
        cout << protok[i] << " ";
    }
    cout << endl;*/
    }
    for(int i = 0; i < n; i++){
        cout << protok[i] << " ";
    }
    return 0;
}