#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int ans[330][330];
//  l---r
// t.....
// -.....
// -.....
// b
vector<string> f;
vector<pair<P,P>> cakes;
void dfs(int t,int b,int l,int r){
	int cnt = 0;
	for(int i = t;i <= b;i++){
		for(int j = l;j <= r;j++){
			if(f[i][j] == '#')cnt++;
		}
	}
	if(cnt == 1){
		cakes.push_back(make_pair(P(t,b),P(l,r)));
		return;
	}
	if(cnt >= 2){
		//縦に切る
		{
			vector<int> berry;
			for(int j = l;j <= r;j++){
				int tmp = 0;
				for(int i = t;i <= b;i++){
					tmp += f[i][j] == '#';
				}
				berry.push_back(tmp);
			}
			rep(i,r-l+1){
				if(berry[i] && berry[i] <cnt){
					//cut
					//(t,b,l,l+i),(t,b,l+i+1,r)
					dfs(t,b,l,l+i);
					dfs(t,b,l+i+1,r);
					return;
				}
			}
		}
		//横に切る
		{
			vector<int> berry;
			for(int i = t;i <= b;i++){
				int tmp = 0;
				for(int j = l;j <= r;j++){
					tmp += (f[i][j] == '#');
				}
				berry.push_back(tmp);
			}
			rep(i,b-t+1){
				if(berry[i] && berry[i] < cnt){
					dfs(t,t+i,l,r);
					dfs(t+i+1,b,l,r);
					return;
				}
			}

		}
	}
}
signed main(){
	int h,w,k;cin >> h >> w >> k;
	f.resize(h);
	rep(i,h)cin >> f[i];
	dfs(0,h-1,0,w-1);
	//分類
	{
		int num = 1;
		for(auto p:cakes){
			//cout << p.first.first << " "<< p.first.second  << " "<< p.second.first<<" " << p.second.second << endl;
			for(int i = p.first.first;i <= p.first.second;i++){
				for(int j = p.second.first;j <= p.second.second;j++){
					ans[i][j] = num;
				}
			}
			num++;
		}
	
	}
	 rep(i,h){
	 	rep(j,w)cout << ans[i][j] << " ";
	 	cout << "\n";
	 }
	return 0;
}

Measured memory_bytes: 8556