#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> s(H);
	for (auto &x : s) {
		cin >> x;
	}

	vector<vector<int>> ans(H, vector<int>(W, 0));
	int id = 1;

	for (int i = 0; i < H; ++i) {
		if (s[i].find('#') != string::npos) {
			int j = 0;
			for (; j < W && s[i][j] == '.'; ++j) {
				ans[i][j] = id;
			}
			if (j < W) {
				ans[i][j] = id;
				++j;
			}
			for (; j < W && s[i][j] == '.'; ++j) {
				ans[i][j] = id;
			}
			for (; j < W; ++j) {
				if (s[i][j] == '#') {
					++id;
				}
				ans[i][j] = id;
			}
			++id;
		}
	}

	for (int i = 0; i < H; ++i) {
		if (ans[i][0] != 0) {
			for (int k = i + 1; k < H; ++k) {
				if (ans[k][0] == 0) {
					ans[k] = ans[k - 1];
				}
			}
			for (int k = i - 1; k >= 0; --k) {
				if (ans[k][0] == 0) {
					ans[k] = ans[k + 1];
				}
			}
			break;
		}
	}

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}