#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int n,h,i,j;
	
	scanf("%d %d",&h,&n);
	int mat[h][n];
	int rez[]={1,1,1};
	
	for(i=0;i<h;i++){
		for(j=0;j<n;j++){
			scanf("%1d",&mat[i][j]);
		}
	}
	printf("\n");
	
	
	for(j=0;j<h;j++){
		for(i=0;i<n;i++){
			
			rez[i];
			mat[i][j];
			
			if(mat[j][i]==0 && mat[j][i-1]!=0 && mat[j][i+1]!=0){
				if(i==0){ 
					rez[i+1]+=rez[i];
					rez[i]=0;
				}
				else if(i==(n-1)){
					rez[i-1]+=rez[i];
					rez[i]=0;
				}
				else if(rez[i]%2==0){
					rez[i-1]+=rez[i]/2;
					rez[i+1]+=rez[i]/2;
					rez[i]=0;
				}
				else if((j+1)%2==0){
					rez[i]--;
					rez[i+1]++;
					rez[i-1]+=rez[i]/2;
					rez[i+1]+=rez[i]/2;
					rez[i]=0;
				}
				else if((j+1)%2==1){
					rez[i]--;
					rez[i-1]++;
					rez[i-1]+=rez[i]/2;
					rez[i+1]+=rez[i]/2;
					rez[i]=0;
				}
			}
			
		}
		
		for(i=0;i<n;i++){
		printf("%d ",rez[i]);
	}
	printf("\n");
	}
	
	
	
	
	return 0;
}