#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

int main() {
	int c, b, nmb = 0, k; std::cin >> c >> b;
	std::vector<std::vector<int> > a(c, std::vector<int>(b, 0));
	for (int i = 0; i < c; ++i)
		for (int j = 0; j < b; ++j)
			std::cin >> a[i][j];
	if (a[0][0] == 0) {
		int counter = 1;
		for (k = 1; k < b; ++k) {
			if (a[0][k] == 0) {
				counter++;
			}
			else {
				a[0][k] += counter;
				break;
			}
		}
		nmb = k;
	}
	for (int i = nmb; i < b; ++i) {
		if (a[0][i] != 0) {
			for (int j = i + 1; j < b; ++j) {
				if (a[0][j] == 0) {
					a[0][i]++;
				}
				else {
					break;
				}
			}
		}

	}
	for (int i = c - 1; i < c; ++i)
		for (int j = 0; j < b; ++j)
			std::cout << a[i][j] << ' '; 
	return 0;
}