#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    uint32_t h, n;

    cin >> h >> n;

    bool waterfall[h][n];

    for(int i = 0; i < h; i++)
        for(int j = 0; j < n; j++)
            cin >> waterfall[i][j];

    uint32_t water_amount[n], temp_water_amount[n];
    fill_n(water_amount, n, 1);

    uint32_t last_open_cell, water_on_hold;

    for(int i = 0; i < h; i++){
        fill_n(temp_water_amount, n, 0);
        last_open_cell = -1;
        water_on_hold = 0;

        for(int j = 0; j < n; j++){
            if(waterfall[i][j]){
                last_open_cell = j;
                temp_water_amount[j] += water_on_hold + water_amount[j];
                water_on_hold = 0;
            }else{
                uint32_t split = water_amount[j] / 2;
                water_on_hold += split;
                if(last_open_cell != -1)
                    temp_water_amount[last_open_cell] += split * (1 + (j == n - 1));
                else
                    water_on_hold += split;

                if(water_amount[j] % 2){
                    if((i & 1 && j != n - 1) || last_open_cell == -1)
                        water_on_hold++;
                    else
                        temp_water_amount[last_open_cell]++;
                }
            }
        }

        memcpy(water_amount, temp_water_amount, sizeof(water_amount));
    }
    for(int i = 0; i < n; i++)
        cout << water_amount[i] << " ";
    cout << endl;
}