#include <iostream>
#include <string>
#include <vector>
using namespace std;


int main()
{
	int input;
	int h;
	int n;
	bool nullcheck = 0;
	int nullcount = 0;
	bool leftcheck = 0;
	int leftcount = 0;
	bool rightcheck = 0;
	int rightcount = 0;
	int leftmargin = 0;
	int rightmargin = 0;

	
	typedef vector<vector<bool>> boolMatrix;

	cin >> h;
	cin >> n;

	vector<bool> x(n);

	vector<int> in(n);
	vector<int> out(n);

	boolMatrix map(h,x);

	for (int i = 0; i < n; i++) {
		in[i] = 1;
		out[i] = 0;
	}

	for (int k = 0; k < h; k++) {
		for (int i = 0; i < n; i++) {
			cin >> input;
			map[k][i] = input;
		}
	}


	for (int k = 0; k < h; k++) {
		nullcheck = 0;

		while (nullcheck == 0) {
			nullcount = 0;
			for (int i = 0; i < n; i++) {
			
				leftcount = 0;
				rightcount = 0;
				leftcheck = 0;
				rightcheck = 0;
				
				for (int lfchkc = i; lfchkc >= 0; lfchkc--) {
					if (map[k][lfchkc] != 0) {
						leftcount++;
						if (leftcount == 1) {
							leftmargin = lfchkc;
						}
					}

				}
				if (leftcount == 0) {
					leftcheck = 1;
				}

				
				for (int rhchkc = i; rhchkc < n; rhchkc++) {
					if (map[k][rhchkc] != 0) {
						rightcount++;
						if (rightcount == 1) {
							rightmargin = rhchkc;
						}
					}

				}
				if (rightcount == 0) {
					rightcheck = 1;
				}


				if (map[k][i] == 1) {
					out[i] = out[i] + in[i];
					in[i] = 0;
				}
				if (map[k][i] == 0) {
					if (leftcheck == 1) {
						in[i + 1] = in[i + 1] + in[i];
						in[i] = 0;
					}
					if (rightcheck == 1) {
						in[i - 1] = in[i - 1] + in[i];
						in[i] = 0;
					}
					if (leftcheck == 0 && rightcheck == 0) {


						if (in[i] % 2 == 0) {
							in[leftmargin] = in[leftmargin] + in[i] / 2;
							in[rightmargin] = in[rightmargin] + in[i] / 2;
							in[i] = 0;
						}
						if (in[i] % 2 != 0) {
							if (k % 2 != 0) {
								in[rightmargin] = in[rightmargin] + ((in[i] - 1) / 2) + 1;
								in[leftmargin] = in[leftmargin] + (in[i] - 1) / 2;
								in[i] = 0;
							}
							if (k % 2 == 0) {
								in[rightmargin] = in[rightmargin] + ((in[i] - 1) / 2);
								in[leftmargin] = in[leftmargin] + ((in[i] - 1) / 2) + 1;
								in[i] = 0;
							}
						}
					}
				}

			}
			for (int countiter = 0; countiter < n; countiter++) {
				if (in[countiter] != 0) {
					nullcount++;
				}
			}
			if (nullcount == 0) {
				nullcheck = 1;
			}

		}
		in = out;
		for (int nuller = 0; nuller < n; nuller++) {
			out[nuller] = 0;
		}
	}

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