#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
#define print(x) std::cout << x << std::endl;
#define debug(x) std::cout << #x << " = " << x << std::endl;
#define debugHex(x) std::cout << #x << " = 0x" << std::hex << std::setfill('0') << std::setw(8) << x << std::dec << std::endl;
#define DWORD unsigned int
#define BOOL bool

struct flow
{
	BOOL flowable;
	DWORD streamCount;
	DWORD* contiguous;
	DWORD startPos;
	flow(BOOL w = 0, DWORD x = 0, DWORD y = 0, DWORD z = 0)
	{
		contiguous = (DWORD*)malloc(4);
		streamCount = x;
		*contiguous = y;
		startPos = z;
		flowable = w;
	}
};

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	vector<vector<flow>> wfall;
	DWORD h, n; cin >> h >> n;
	vector<flow> tmpVec;
	for (DWORD i = 0; i < n+1; i++)
	{
		flow tmp(1, 1, 0, 0);
		tmpVec.push_back(tmp);
	}
	wfall.push_back(tmpVec);

	for (DWORD i = 1; i < h+1; i++)
	{
		vector<flow> row;
		row.push_back(flow());
		flow tmp1; 
		cin >> tmp1.flowable;
		tmp1.streamCount = 0;
		tmp1.startPos = 1;
		*tmp1.contiguous = 1;
		row.push_back(tmp1);
		for (DWORD j = 2; j < n+1; j++)
		{
			flow tmp2;
			cin >> tmp2.flowable;
			tmp2.streamCount = 0;
			if (tmp2.flowable == 0)
			{
				if (row[j - 1].flowable == 0)
				{
					tmp2.contiguous = row[j - 1].contiguous;
					(*tmp2.contiguous)++;
					tmp2.startPos = row[j - 1].startPos;
				}
				else
				{
					*tmp2.contiguous = 1;
					tmp2.startPos = j;
				}
			}
			row.push_back(tmp2);
		}
		wfall.push_back(row);
	}

	for (DWORD i = 1; i < h + 1; i++)
	{
		for (DWORD j = 1; j < n + 1; j++)
		{
			flow curr = wfall[i][j];
			flow prev = wfall[i - 1][j];
			if (curr.flowable == 0)
			{
				if (j + *(curr.contiguous) >= n + 1)
				{
					while (j < n + 1)
						wfall[i][curr.startPos - 1].streamCount += wfall[i - 1][j++].streamCount;
					break;
				}
				else if (j == 1 && *curr.contiguous > 1)
				{
					while (j <= *(curr.contiguous))
						wfall[i][*curr.contiguous + 1].streamCount += wfall[i - 1][j++].streamCount;
					j--; //inc on cont
					continue;
				}
				else if (j == 1 && *curr.contiguous == 1)
				{
					wfall[i][j + 1].streamCount += prev.streamCount;
					continue;
				}
				if (*curr.contiguous > 1)
				{
					DWORD endPos = curr.startPos + *(curr.contiguous);
					while (j < endPos)
					{
						prev = wfall[i - 1][j];
						if (prev.flowable == 0) { ++j; continue; }
						if (prev.streamCount % 2 == 1 && i % 2 == 1)
							wfall[i][curr.startPos - 1].streamCount++;
						else if (prev.streamCount % 2 == 1 && i % 2 == 0)
							wfall[i][endPos].streamCount++;
						wfall[i][curr.startPos - 1].streamCount += (prev.streamCount) / 2;
						wfall[i][endPos].streamCount += (prev.streamCount) / 2;
						j++;
					}
					j--; //inc on cont
				}
				else
				{
					if (prev.streamCount % 2 == 1 && i % 2 == 1)
						wfall[i][j - 1].streamCount += 1;
					else if (prev.streamCount % 2 == 1 && i % 2 == 0)
						wfall[i][j + 1].streamCount += 1;
					wfall[i][j - 1].streamCount += (prev.streamCount) / 2;
					wfall[i][j + 1].streamCount += (prev.streamCount) / 2;
				}
			}
			else  wfall[i][j].streamCount += wfall[i - 1][j].streamCount;
		}
		//cout << endl;
		//for (DWORD j = 1; j < n + 1; j++) cout << wfall[i][j].streamCount << " ";
		//cout << endl;
	}

	for (DWORD j = 1; j < n + 1; j++)
	{
		flow curr = wfall[h][j];
		if (curr.flowable)
			cout << curr.streamCount << " ";
		else cout << 0 << " ";
	}
	cout << endl;
}