#include <iostream>
#include <vector>


bool IsAv(std::vector<int>v, int n,bool dir) {
	if (dir) {
		for (int i = n; i < int(v.size()); ++i)
			if (v[i] == 1)
				return true;
		return false;
	} 
	else
	{
		for (int i = n; i >= 0; --i)
			if (v[i] == 1)
				return true;
		return false;
	}
}

std::vector<int> eh(std::vector<int>r, std::vector<std::vector<int> > v, int rn) {
//	for (auto i : r) std::cout << i << " ";
//	std::cout << std::endl;
	if (rn == int(v.size())) return r; int r1 = 0, s;
	std::vector<int> p(r.size());
	for (int i = 0; i < int(r.size()); ++i) if (v[rn][i] == 1) p[i] = r[i];
	for(int i = 0; i < int(r.size());++i)
	{
		r1 = 0;
		if (v[rn][i] == 0 && r[i] > 0)
		{
			if (i == 0) 
			{
				for (int j = 0; j < int(r.size()); ++j)
					if (v[rn][j] == 1)
					{
						p[j] += r[i];
						break;
					}
			}
			else
			{
				if (i == (int(r.size()) - 1))
				{
					for (int j = int(r.size()) - 1; j >= 0; --j)
						if (v[rn][j] == 1)
						{
							p[j] += r[i];
							break;
						}
				}
				else
				{
					if (IsAv(v[rn], i, 1))
					{
						if (IsAv(v[rn], i, 0))
						{
							if (r[i] % 2) {
								r1 = 1;
								s = (r[i] - 1) / 2;
							}
							else
							{
								s = r[i] / 2;
							}
							for (int j = i; j < int(r.size()); ++j)
								if (v[rn][j] == 1)
								{
									p[j] += s;
									if ((rn % 2))
										p[j] += r1;
									break;
								}
							for (int j = i; j >= 0; --j)
								if (v[rn][j] == 1)
								{
									p[j] += s;
									if (!(rn % 2))
										p[j] += r1;
									break;
								}
						}
						else
						{
							for (int j = i; j < int(r.size()); ++j)
								if (v[rn][j] == 1)
								{
									p[j] += r[i];
									break;
								}
						}
					}
					else
					{
						for (int j = i; j >= 0; --j)
							if (v[rn][j] == 1)
							{
								p[j] += r[i];
								break;
							}
					}
				}
			}
		}
		else
		{
			continue;
		}
	}
	return eh(p, v, rn + 1);
}

int main() {
	int x, y; std::cin >> y >> x; std::vector<std::vector<int> >a(y, std::vector<int>(x));
	for (auto& i : a) for (auto& j : i) std::cin >> j;
	std::vector<int>b = eh(std::vector<int>(x,1), a, 0);
	for (auto i : b) std::cout << i << " ";
	return 0;
}