#include <stdio.h>
#define MAX 1000

int vodopad[MAX][MAX];
int protok[MAX][MAX];

void unos(int h, int n){
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < n; ++j){
            scanf("%i", &vodopad[i][j]);
        }
    }
}

void ispisiPoslednjiRed(int h, int n){
    for(int j = 0; j < n; ++j){
        printf("%i ", protok[h][j]);
    }
}

bool parnost(int n){
    if(n % 2 == 0){
        return true;
    }
    return false;
}

void namestiVodu(int n){
    for(int i = 0; i < n; ++i){
        protok[0][i] = 1;
    }
}

int proveriDesno(int i, int j, int n){
    int br = 0;
    while(vodopad[i][j] != 1 && j <= n-1){
        j++;
        br++;
    }
    return br-1;
}

int proveriLevo(int i, int j){
    int br = 0;
    while(vodopad[i][j] != 1 && j >= 0){
        j--;
        br++;
    }
    return br-1;
}

void pomeriVodu(int i, int j, int n){
    int l = proveriLevo(i, j);
    int d = proveriDesno(i, j, n);
    if(j==0 || j==n-1){
        if(j == 0){ protok[i+1][j+1+d] += protok[i][j]; }
        else{ protok[i+1][j-1-l] += protok[i][j]; }
    }
    else{
        if(protok[i][j] % 2 == 0){
            protok[i+1][j+1+d] += protok[i][j]/2;
            protok[i+1][j-1-l] += protok[i][j]/2;
        }
        else{
            if(parnost(i+1)){
                protok[i+1][j+1+d] += (protok[i][j]/2)+1;
                protok[i+1][j-1-l] += protok[i][j]/2;
            }
            else{
                protok[i+1][j+1+d] += protok[i][j]/2;
                protok[i+1][j-1-l] += (protok[i][j]/2)+1;
            }
        }
    }
}

int main()
{
   int h, n;
   scanf("%i %i", &h, &n);
   unos(h, n);
   namestiVodu(n);

   for(int i = 0; i < h; ++i){
        for(int j = 0; j < n; ++j){
            if(vodopad[i][j]==1){ protok[i+1][j] += protok[i][j]; }
            else{
                pomeriVodu(i, j, n);
            }
        }
   }
   ispisiPoslednjiRed(h, n);
}