#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
using namespace std;

int H,W,K,A[309][309],num,cnt[309];
char c[309][309];

void cut(int cl, int cr) {
	vector<int> P;
	erep(i,cl,cr) {
		erep(j,1,W) {
			if (c[i][j] == '#') P.push_back(j);
		}
	}
	sort(P.begin(), P.end());
	rep(i,0,P.size()) {
		int v1 = 1, v2 = W;
		if (i >= 1) v1 = P[i - 1] + 1;
		if (i < (int)P.size() - 1) v2 = P[i];

		num++;
		erep(j,cl,cr) {
			erep(k,v1,v2) A[j][k] = num;
		}
	}
}

int main() {
	cin >> H >> W >> K;
	erep(i,1,H) {
		erep(j,1,W) {
			cin >> c[i][j];
			if (c[i][j] == '#') cnt[i]++;
		}
	}

	vector<int> vec;
	erep(i,1,H) if (cnt[i]) vec.push_back(i);
    rep(i,0,vec.size()) {
		int v1 = 1, v2 = H;
		if (i>0) v1 = vec[i - 1] + 1;
		if (i<(int)vec.size()-1) v2 = vec[i];
		cut(v1, v2);
	}

	erep(i,1,H) {
		erep(j,1,W)cout<<A[i][j]<<" ";
		puts("");
	}
}