#include <bits/stdc++.h>

using namespace std;

vector<int> voda[1000000];
vector<int> mat[1000000];
vector< pair<int,int> > next[1000000];

int n,h;

void p () {
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<n;j++)
		{
			cout << mat[i][j] << " ";
		}
		cout << endl;
	}
}

void p2 () {
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<n;j++)
		{
			cout << "{" << next[i][j].first << "," << next[i][j].second << "}";
		}
		cout << endl;
	}
}

int main ()
{

	cin >> h >> n;
	
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<n;j++)
		{
			int k;
			cin >> k;
			voda[i].push_back(k);
			mat[i].push_back(0);
			next[i].push_back({0,0});
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(voda[i][j] == 1) next[i][j].first = j;
			else {
				if(j > 0)
				next[i][j].first = next[i][j-1].first;
				else
				next[i][j].first = -1;
			}
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=n-1;j>=0;j--)
		{
			if(voda[i][j] == 1) next[i][j].second = j;
			else {
				if(j < n-1)
				next[i][j].second = next[i][j+1].second;
				else
				next[i][j].second = -1;
			}
		}
	}
	//p2();
	for(int i=0;i<n;i++)
	{
		if(next[0][i].first != -1)
		mat[0][next[0][i].first] += 1;
		else
		mat[0][next[0][i].second] +=1;
	}
	for(int i=0;i<h-1;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(voda[i+1][j] == 1) mat[i+1][j] += mat[i][j];
			else {
				if(next[i+1][j].first == -1)
				{
					mat[i+1][next[i+1][j].second] += mat[i][j];
				}
				else if(next[i+1][j].second == -1)
				{
					mat[i+1][next[i+1][j].first] += mat[i][j];
				}
				else {
					if(mat[i][j] % 2 == 0)
					{
						mat[i+1][next[i+1][j].first] += mat[i][j]/2;
						mat[i+1][next[i+1][j].second] += mat[i][j]/2;
					}
					else
					{
						mat[i+1][next[i+1][j].first] += (mat[i][j]-1)/2;
						mat[i+1][next[i+1][j].second] += (mat[i][j]-1)/2;
						
						if(i%2==1) mat[i+1][next[i+1][j].first]++;
						else mat[i+1][next[i+1][j].second]++;
					}
				}
			}
		}
	}
	//p();
	for(int i=0;i<n;i++)
	{
		cout << mat[h-1][i] << " ";
	}
	
}