/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
Shahat , Omar
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include <random>
#include <complex> 
using namespace std;
#define ll long long
#define ld double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
#define holla(x,y) cout <<"# holla "<<y<<" "<< #x << " is " << x << endl;
typedef complex<long double> point;
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(), (n).end()
#define EPS 1e-9
#define OO 1e9
#define X real()
#define Y imag()
#define vec(a,b) ((b)-(a))
#define polar(r,t) ((r)*exp(point(0,(t))))
#define angle(v) (atan2((v).Y,(v).X))
#define length(v) ((long double)hypot((v).Y,(v).X))
#define lengthSqr(v) (dot(v,v))
#define dot(a,b) ((conj(a)*(b)).real())
#define cross(a,b) ((conj(a)*(b)).imag())
#define rotate(v,t) (polar(v,t))
#define rotateabout(v,t,a)  (rotate(vec(a,v),t)+(a))
#define reflect(p,m) ((conj((p)/(n)))*(n))
#define normalize(p) ((p)/length(p))
#define same(a,b) (lengthSqr(vec(a,b))<EPS)
#define mid(a,b) (((a)+(b))/point(2,0))
#define perp(a) (point(-(a).Y,(a).X))
#define colliner pointOnLine 
enum STATE { IN, OUT, BOUNDRY };
const double PI = acos(-1.0);
#ifndef ONLINE_JUDGE
int __builtin_popcount(int mask) {
	int cnt = 0;
	for (int i = 0; i < 23; i++)
		if (mask&(1 << i)) ++cnt;
	return cnt;
}
#endif
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };// remeber the secret ultimate move
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };// the 0,0 not moving move 
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1,0 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2,0 };
const ld eps = 1e-9;
const int N = 300 + 50, M = 500 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
string grid[N];
int cnt[N];
int ans[N][N];

int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//freopen("fetiera.in", "r", stdin);
	//kolo ray7 , ya 5rabyy
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		cin >> grid[i];
		for (auto e : grid[i])
			cnt[i] += e == '#';
	}
	int col = 1; int add = 1;
	for (int i = 0; i < n; i++) {
		add = 1;
		int c = cnt[i];
		for (int j = 0; j < m&&cnt[i]; j++) {
			ans[i][j] = col;
			if (grid[i][j] == '#') {
				if (c > 1)
					col++, c--;
			}
		}
		if (cnt[i])col += add;
	}
	vector<vector<pair<int, int>>>adj(col);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (ans[i][j])
				adj[ans[i][j]].push_back({ i,j });
		}
	}
	//return 0;
	for (auto i = 1; i < col; i++) {
		int xlast = adj[i].back().first;
		int xfirst = adj[i][0].first;
		int ylast = adj[i].back().second;
		int yfirst = adj[i][0].second;
		for (int j = xfirst - 1; j > -1; j--) {
			if (ans[j][yfirst])break;
			xfirst = j;
			for (int k = yfirst; k <= ylast; k++)
				ans[j][k] = i;
		}
		for (int j = xlast + 1; j < n; j++) {
			if (ans[j][yfirst])break;
			xlast = j;
			for (int k = yfirst; k <= ylast; k++)
				ans[j][k] = i;
		}
		for (int j = yfirst; j > -1; j--) {
			if (ans[xfirst][j])break;
			yfirst = j;
			for (int k = xfirst; k <= xlast; k++)
				ans[k][j] = i;
		}
		for (int j = ylast; j < m; j++) {
			if (ans[xfirst][j])break;
			ylast = j;
			for (int k = xfirst; k <= xlast; k++)
				ans[k][j] = i;
		}
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cout << ans[i][j] << " \n"[j == m - 1];
	return 0;
}

Measured memory_bytes: 6272