#include <iostream>

using namespace std;

bool xdpiski[1000000];
int protok[1000000];
int protokpomoc[1000000];

int main()
{
	int h, n, k, m,p; cin >> h >> n;
	for (int i = 0; i < n; i++) protok[i] = 1;
	for (int i = 0; i < h; i++)
	{
		k = 1;
		m = n - 2;
		for (int j = 0; j < n; j++) cin >> xdpiski[j];
		if (xdpiski[0] == 1) protokpomoc[0] += protok[0];
		else 
		{ 
			while (xdpiski[k] == 0) k++;
			for (int j = 0; j < k; j++)
			{
				protokpomoc[k] += protok[j];
				protokpomoc[j] = 0;
			}
		}
		if (xdpiski[n-1] == 1) protokpomoc[n-1] += protok[n-1];
		else 
		{ 
			while (xdpiski[m] == 0) m--;
			for (int j = n-1; j>m; j--)
			{
				protokpomoc[m] += protok[j];
				protokpomoc[j] = 0;
			}
		}	
		for (int j = k; j <= m; j++)
		{
			if (xdpiski[j] == 1) protokpomoc[j] += protok[j];
			else
			{
				p = j + 1;
				while (xdpiski[p] == 0) p++;
				protokpomoc[j - 1] += protok[j]/2;
				protokpomoc[p] += protok[j]/2;
				if (protok[j] % 2 == 1)
				{
					if (i % 2 == 1) protokpomoc[p] += 1;
					else protokpomoc[j - 1] += 1;
				}
			}
		}
		for (int j = 0; j < n; j++) protok[j] = protokpomoc[j];
		for (int j = 0; j < n; j++) protokpomoc[j] = 0;
	}
	for (int i = 0; i < n; i++) cout << protok[i] << " ";
	cout << endl;
    return 0;
}