#include <bits/stdc++.h>
using namespace std;
int main()
{
	long h,n;
	cin>>h>>n;
	int a[h][n];
	bool left,right;
	long right1,left1;
	long protok[n];
	for(int u=0;u<n;u++) protok[u]=1;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
		for(int l=0;l<n;l++)
		{
			if(a[i][l]==0)
			{
				right=false;
				for(int k=l;k<n;k++)
				{
					if(a[i][k]==1&&right==false)
					{
						right1=k;
						right=true;
					}
				}
				left=false;
				for(int q=l;q>=0;q--)
				{
					if(a[i][q]==1&&left==false)
					{
						left1=q;
						left=true;
					}
				}
				//cout<<left1<<" "<<right1<<endl;
				//cout<<left<<" "<<right<<endl;
				if(left and right)
				{
					if(protok[l]%2==0)
					{
						protok[left1]+=protok[l]/2;
						protok[right1]+=protok[l]/2;
						protok[l]=0;
					}
					else
					{
						if(i%2==0)
						{
							protok[left1]+=protok[l]/2+1;
							protok[right1]+=protok[l]/2;
							protok[l]=0;
						}
						else
						{
							protok[left1]+=protok[l]/2;
							protok[right1]+=protok[l]/2+1;
							protok[l]=0;
						}
					}
				}
				else if(left==true&&right==false)
				{
					protok[left1]+=protok[l];
					protok[l]=0;
				}
				else
				{
					protok[right1]+=protok[l];
					protok[l]=0;
				}
			}
		}
		//for(int z=0;z<n;z++) cout<<protok[z]<<" ";
	}
	for(int z=0;z<n;z++) cout<<protok[z]<<" ";
	cout<<endl;
	return 0;
}