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

int main()
{
	long int h,n;
	scanf("%ld %ld", &h,&n);
	short int matrica[h][n];
	long int protok[n];
	long int temp;
	long int k,q;

	for (long int i = 0; i<n; i++)      //Definisanje niza protok
	{
		protok[i] = 1;
	}

	for (long int i = 0; i<h; i++)      //Unos matrice
	{
		for (long int j = 0; j<n; j++)
		{
        scanf("%hd", &matrica[i][j]);
		}
	}

	for (long int i =0; i<h; i++)
	{
		for(long int j =0; j<n; j++)
		{
			if (matrica[i][j] == 0)
			{
				if (protok[j] == 1)
				{
					if(j==0)       //desno i pocetak i protok 1
					{
							if(matrica[i][j+1] == 1)
							{
								temp = protok[j];
								protok[j] -= protok[j];
								protok[j+1] += temp;
							}
							else
							{
								k = j;
								while(matrica[i][k+1]==0)
								{
									k++;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k+1] += temp;
							}
					}
					else if(j==n-1)  //levo i kraj i protok 1
					{
						if(matrica[i][j-1] == 1)
							{
								temp = protok[j];
								protok[j] -= protok[j];
								protok[j-1] += temp;
							}
							else
							{
								k = j;
								while(matrica[i][k-1]==0)
								{
									k--;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k-1] += temp;
							}
					}
					else if ((i+1)%2 == 0)   //desno i sredina i protok>1
					{
						if(matrica[i][j+1] == 1)
							{
							temp = protok[j];
							protok[j] -= protok[j];
							protok[j+1] += temp;
							}
							else
							{
								k = j;
								while(matrica[i][k+1]==0)
								{
									k++;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k+1] += temp;
							}
					}
					else if ((i+1)%2 != 0)    //levo i sredina i protok=1
					{
						if(matrica[i][j-1] == 1)
							{
							temp = protok[j];
							protok[j] -= protok[j];
							protok[j-1] += temp;
							}
							else
							{
								k = j;
								while(matrica[i][k-1]==0)
								{
									k--;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k-1] += temp;
							}
					}
				}


				else if (protok[j] >1)
				{
					if(j==0)     //desno i pocetak i protok>1
					{
						if(matrica[i][j+1] == 1)
							{
								temp = protok[j];
								protok[j] -= protok[j];
								protok[j+1] += temp;
							}
							else
							{
								k = j;
								while(matrica[i][k+1]==0)
								{
									k++;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k+1] += temp;
							}					}
					else if(j==n-1)     //levo i kraj i protok>1
					{
						if(matrica[i][j-1] == 1)
							{
								temp = protok[j];
								protok[j] -= protok[j];
								protok[j-1] += temp;
							}
							else
							{
								k = j;
								while(matrica[i][k-1]==0)
								{
									k--;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k-1] += temp;
							}
					}
					else if ((i+1)%2 == 0)   //desno i sredina i protok>1
					{
						if((matrica[i][j+1]) == 1 && (matrica[i][j-1] == 1))     //obe strane su slobodne
							{
								temp = protok[j];
							protok[j] -= protok[j];
							protok[j+1] += temp - temp/2;
							protok[j-1] += temp/2;
							}
							else if ((matrica[i][j+1] == 0) && (matrica[i][j-1] == 1))    //desno ima stena a levo nema
							{
								k = j;
								while(matrica[i][k+1]==0)
								{
									k++;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k+1] += temp - temp/2;
								protok[j-1] += temp/2;
							}
							else if ((matrica[i][j+1] == 0) && (matrica[i][j-1] == 0))  //desno ima stena I levo ima stena
							{
								k = j;
								q = j;
								while(matrica[i][k+1]==0)
								{
									k++;
								}
								while(matrica[i][q-1]==0)
								{
									q--;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k+1] += temp - temp/2;
								protok[q-1] += temp/2;
							}
							else if ((matrica[i][j+1] == 1) && (matrica[i][j-1] == 0)) //desno nema stena a levo ima
							{
								k = j;
								while(matrica[i][k-1]==0)
								{
									k--;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[j+1] += temp - temp/2;
								protok[k-1] += temp/2;
							}
					}
					else if ((i+1)%2 != 0)    //levo i sredina i protok>1
					{
						if((matrica[i][j+1]) == 1 && (matrica[i][j-1] == 1))     //obe strane su slobodne
							{
								temp = protok[j];
							protok[j] -= protok[j];
							protok[j-1] += temp - temp/2;
							protok[j+1] += temp/2;
							}
							else if ((matrica[i][j+1] == 0) && (matrica[i][j-1] == 1))    //desno ima stena a levo nema
							{
								k = j;
								while(matrica[i][k+1]==0)
								{
									k++;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[j-1] += temp - temp/2;
								protok[k+1] += temp/2;
							}
							else if ((matrica[i][j+1] == 0) && (matrica[i][j-1] == 0))  //desno ima stena I levo ima stena
							{
								k = j;
								q = j;
								while(matrica[i][k+1]==0)
								{
									k++;
								}
								while(matrica[i][q-1]==0)
								{
									q--;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[q-1] += temp - temp/2;
								protok[k+1] += temp/2;
							}
							else if ((matrica[i][j+1] == 1) && (matrica[i][j-1] == 0)) //desno nema stena a levo ima
							{
								k = j;
								while(matrica[i][k-1]==0)
								{
									k--;
								}
								temp = protok[j];
								protok[j] -= protok[j];
								protok[k-1] += temp - temp/2;
								protok[j+1] += temp/2;
							}
					}
				}
			}

		}
	}

	for (long int i =0; i<n; i++)
	{
		printf("%ld ", protok[i]);
	}

	return 0;
}