#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
        
        dividend %= mod;
        divisor %= mod;
    }
    return (dividend %mod) / (divisor%mod);
}

inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
ll facctorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    ll res = 0;
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h){
        cin >> s[i];
    }
    
    ll count = 1;
    vector<vector<ll>> answer(h, vector<ll>(w));
    
    bool flag = false;
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#'){
                if(flag){
                    count ++;
                }
                flag = true;
            }
            
            answer[i][j] = count;
        }
        if(flag == false){
            answer[i][0] = 0;
            continue;
        }
        
        flag = false;
        count ++;
    }
    
    rep(i, h){
        if(answer[i][0] == 0){
            ll pos = -1;
            for(int j = 1; i - j >= 0; j ++){
                if(answer[i-j][0] != 0){
                    pos = i - j;
                    break;
                }
            }
            if(pos == -1){
                for(int j = 1; ; j ++){
                    if(answer[i+j][0] != 0){
                        pos = i + j;
                        break;
                    }
                }
            }
            
            rep(j, w){
                answer[i][j] = answer[pos][j];
            }
        }
        rep(j, w){
            cout << answer[i][j] << " ";
        }
        cout << endl;
    }
//    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1664