#include <iostream>
#include <cstdio>

using namespace std;

int* read(int n) {
	int* t = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", t + i);
	return t;
}

void write(int n, int *t) {
	for (int i = 0; i < n; i++)
		printf("%d ", t[i]);
	//cout << endl;
}

int main() {
	int h, n;
	cin >> h >> n;
	int* t = new int[n];
	for (int i = 0; i < n; i++)
		t[i] = 1;
	for (int p = 1; h > 0; h--, p = 1 - p) {
		int* x = read(n);
		int* y = new int[n];
		for (int i = 0; i < n; i++)
			y[i] = 0;
		for (int i = 0; i < n;) {
			if (x[i]) {
				y[i] += t[i];
				i++;
			}
			else {
				int s = t[i];
				int j;
				for (j = i + 1; j < n && !x[j]; j++)
					s += t[j];

				if (i == 0)
					y[j] += s;
				else if (j == n)
					y[i - 1] += s;
				else {
					y[i - 1] += s / 2;
					y[j] += s / 2;
					if (s % 2 == 1) {
						if (p % 2 == 0)
							y[j]++;
						else
							y[i - 1]++;
					}
				}
				//write(n, y);
				i = j;
			}
		}
		delete[] x;
		delete[] t;
		t = y;
	}
	write(n, t);
	delete[] t;
}