#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tpl;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };




/******************************************************************************************/



//素数判定
bool is_prime(ll n) {
	for (ll i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return n != 1;//1の場合は除外
}



//約数の列挙
template<typename T>
vector<T> divisor(T n) {
	vector<T> res;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) {
				res.push_back(n / i);
			}
		}
	}
	return res;
}




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}



//繋げる方向を一方向にする
typedef struct union_find {

	vector<ll> pa;//親
	vector<ll> ra;//木の深さ
	vector<ll> siz;
	//n要素で初期化
	void init(ll n) {
		pa.resize(n);
		ra.resize(n);
		siz.resize(n);
		for (ll i = 0; i < n; i++) {
			pa[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
			ra[i] = 0LL;/*各ノード自体の高さは0*/
			siz[i] = 1LL;
		}
	}
	//木の根を求める
	ll find(ll x) {
		if (pa[x] == x) {
			return x;/*根ならそのノードの番号を返す*/
		}
		else {
			return pa[x] = find(pa[x]);/*根でないならさらにノードの根を探す*/
		}
	}

	//xとyの属する集合を併合する
	void unite(ll x, ll y) {
		x = find(x);//xの根の番号を探す
		y = find(y);//yの根の番号を探す
		if (x == y) {//一致すればつながっている
			return;
		}
		pa[y] = x;
		siz[x] += siz[y];
	}

	//xとyが同じ集合に属するか判定
	bool same(ll x, ll y) {
		return find(x) == find(y);//同じ集合なら1、違うなら0が返る
	}
}UF;


char mp[305][305];
int ans[305][305];

int main() {

	int h, w, k;
	cin >> h >> w >> k;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> mp[i][j];
			ans[i][j] = -1;
		}
	}
	
	
	int cnt = 1;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (ans[i][j] != -1)continue;
			if(mp[i][j]== '#'){

				
				ans[i][j] = cnt;
				for (int y = i + 1; y < h; y++)
				{
					if (mp[y][j] != '#' && ans[y][j] == -1) {
						ans[y][j] = cnt;
					}
					else
					{
						break;
					}

				}
				for (int y = i - 1; y >= 0; y--)
				{
					if (mp[y][j] != '#' && ans[y][j] == -1) {
						ans[y][j] = cnt;
					}
					else
					{
						break;
					}
				}
				cnt++;
			}
		}
	}

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			
			if (ans[i][j] != -1) {

				int num = ans[i][j];
				int right = INF;
				int left = 0;
				for (int y = i; y < h; y++)
				{
					int hoge = j;
					if (ans[y][j] != num)break;
					for (int x = j; x < w; x++)
					{
						if (ans[y][x] == num || ans[y][x] == -1) {
							hoge = x;
						}
						else
						{
							break;
						}
					}

					right = min(right, hoge);
					hoge = j;
					for (int x = j - 1; x >= 0; x--)
					{
						if (ans[y][x] == num || ans[y][x] == -1) {
							hoge = x;
						}
						else
						{
							break;
						}
					}
					left = max(left, hoge);
				}
				
				for (int y = i; y >= 0; y--)
				{
					if (mp[y][j] != num)break;
					int hoge = j;
					for (int x = j; x < w; x++)
					{
						if (ans[y][x] == num || ans[y][x] == -1) {
							hoge = x;
						}
						else
						{
							break;
						}
					}

					right = min(right, hoge);
					hoge = j;
					for (int x = j - 1; x >= 0; x--)
					{
						if (ans[y][x] == num || ans[y][x] == -1) {
							hoge = j;
						}
						else
						{
							break;
						}
					}
					left = max(left, hoge);
				}


				for (int y = i; y < h; y++)
				{
					if (ans[y][j] != num)break;
					for (int x = j; x <= right; x++)
					{
						if (ans[y][x] == num || ans[y][x] == -1) {
							ans[y][x] = num;
						}
						else
						{
							break;
						}
					}

					for (int x = j; x >= left; x--)
					{
						if (ans[y][x] == num || ans[y][x] == -1) {
							ans[y][x] = num;
						}
						else
						{
							break;
						}
					}

				}

				for (int y = i; y >= 0; y--)
				{
					if (ans[y][j] != num)break;
					for (int x = j; x <= right; x++)
					{
						if (ans[y][x] == num || ans[y][x] == -1) {
							ans[y][x] = num;
						}
						else
						{
							break;
						}
					}

					for (int x = j; x >= left; x--)
					{
						if (ans[y][x] == num || ans[y][x] == -1) {
							ans[y][x] = num;
						}
						else
						{
							break;
						}
					}

				}
			}
		}
	}
			


	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (j == 0) {
				cout << ans[i][j];
			}
			else
			{
				cout << " " << ans[i][j];
			}

		}
		cout << endl;

	}



	
	return 0;
}

Measured memory_bytes: 1280