#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}

map< int64_t, ll > prime_factor(int64_t n) {
  map< int64_t, ll > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
// dp[i] := 長さが i の増加部分列として最後尾の要素のとりうる最小値
template<class T> int LIS(vector<T> a,  bool is_strong = true) {
    const T INF = 1<<30; // to be set appropriately
    int n = (int)a.size();
    vector<T> dp(n, INF);
    for (int i = 0; i < n; ++i) {
        if (is_strong) *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
        else *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void foreach_permutation(ll n, std::function<void(ll *)> f) {
  ll indexes[n];
  for (ll i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

long double dist(ll x, ll y, ll x2, ll y2){
	return sqrt((x-x2)*(x-x2) + (y-y2)*(y-y2));
}

const ll MOD = 1000000007;
const ll INF = 1e15;
const int MAX = 10000000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 変数定義start(vectorはresizeしようね)
ll H, W, K;
// 変数定義end
void solve(){
    cin >> H >> W >> K;
    vector< vector<string> > s(H, vector<string>(W));
    vector<string> stmp(H);
    REP(i, H){
        cin >> stmp[i];
    }
    REP(i, H){
        REP(j, W){
            s[i][j] = stmp[i].substr(j, 1);
        }
    }
    //上の段の左側#を見て、左上で埋まってないところをとる、これを全部やったあとに埋まってない点をずっと左をみて埋まってるやつを置いてあげる
    //左の埋まってない点のx座標、上のうまってない点のy座標
    vector< vector<ll> > ans(H, vector<ll>(W));
    REP(i, H){
        REP(j, W){
            ans[i][j] = -1;
        }
    }
    ll notdef_x = 0;
    ll notdef_y = 0;
    ll insert_ans = 0;
    vl view_checker(W);
    REP(i, H){
        view_checker[i] = -1;
    }
    REP(i, H){
        REP(j, W){
            if(s[i][j] == "."){
                if(ans[i][j] == -1){
                    if(i < notdef_y){
                        notdef_y = i;
                    }
                    if(j < notdef_x){
                        notdef_x = j;
                    }
                }
            }
            if(s[i][j] == "#"){
                view_checker[i] = 1;
                insert_ans++;
                REP(k, i - notdef_y + 1){
                    REP(m, j - notdef_x + 1){
                        ans[notdef_y + k][notdef_x + m] = insert_ans;
                    }
                }
                notdef_x = j+1;
            }
            if(j == W-1 && view_checker[i] != -1){
                notdef_y = i + 1;
            }
        }
        notdef_x = 0;
    }
    ll def_x = -1;
    REP(i, H){
        REP(j, W){
            if(ans[i][j] != -1){ def_x = j; }
            if(s[i][j] == "." && ans[i][j] == -1 && def_x != -1){
                view_checker[i] = 1;
                ans[i][j] = ans[i][def_x];
            }
        }
        def_x = -1;
    }
    ll def_y = 0;
    REP(i, H){
        REP(j, W){
            if(ans[i][j] != -1){ def_y = i; }
            if(view_checker[i] == -1){
                ans[i][j] = ans[def_y][j];
            }
        }
    }
    REP(i, H){
        REP(j, W){
            cout << ans[i][j] << " ";
            if(j == W-1){
                cout << endl;
            }
        }
    }
}

int main(){

    //clock_t start = clock();

    cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	//clock_t end = clock();

    //const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
}


Measured memory_bytes: 6528