#include <bits/stdc++.h>
using namespace std;

int lend(int a[], int j){
	int br = 1;
	while(a[--j] != 1) br++;
	return br;
}

int rend(int a[], int j){
	int br = 1;
	while(a[++j] != 1) br++;
	return br;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int h, n;
	cin >> h >> n;
	int a[h][n], c[n];
	for(int i = 0; i < n; i++)
		c[i] = 1;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];

	for(int i = 0; i < h; i++){
		int next[n] = {0};
		for(int j = 0; j < n; j++){
			if(a[i][j] == 1){
				next[j] += c[j];
			}else{
				int lamm = 0, ramm = 0;
				if(c[j]%2){
					if(i%2 == 0) lamm++;
					else ramm++;
					lamm += (c[j]-1)/2;
					ramm += (c[j]-1)/2;
				}else{
					lamm = c[j]/2;
					ramm = c[j]/2;
				}
				if(j == 0){
					if(a[i][1] == 0)
						next[j+rend(a[i],j)] += c[j];
					else next[1] += c[0];
				}
				else if(j == n-1){
					if(a[i][n-2] == 0) 
						next[j-lend(a[i],j)] += c[j];
					else next[n-2] += c[j];
				}
				else if(a[i][j-1] == 0 || a[i][j+1] == 0){
					next[j-lend(a[i],j)] += lamm;
					next[j+rend(a[i],j)] += ramm;
				}
				else{
					next[j-1] += lamm;
					next[j+1] += ramm;
				}
			}
		}
		copy(next, next+n, c);
	}

	for(int i = 0; i < n; i++){
		cout << c[i] << " ";
	}

	return 0;
}