#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int H, W, K;
int color = 0;
vector<vector<int>> yoko(334, vector<int>(334, 0)), tate(334, vector<int>(334, 0));
vector<vector<int>> dp(334, vector<int>(334, 0));
vector<vector<int>> ans(334, vector<int>(334, 0));
vector<vector<char>> fi(334, vector<char>(334, '.'));

void input(){
    cin >> H >> W >> K;
    repr(i, 1, H+1) repr(j, 1, W+1) cin >> fi[i][j];
}

int calc(int sh, int th, int sw, int tw){
    return dp[th][tw] - dp[th][sw-1] - dp[sh-1][tw] + dp[sh-1][sw-1];
}

void rec(int sh, int th, int sw, int tw){
    int straw = dp[th][tw] - dp[th][sw-1] - dp[sh-1][tw] + dp[sh-1][sw-1];
    if(straw == 1){
        ++color;
        repr(i, sh, th+1) repr(j, sw, tw+1) ans[i][j] = color;
        return;
    }

    bool skip = false;
    // 縦に切る
    repr(j, sw, tw){
        if(calc(sh, th, sw, j) != straw && calc(sh, th, sw, j) != 0){
            skip = true;
            rec(sh, th, sw, j);
            rec(sh, th, j+1, tw);
            break;
        }
    }
    if(!skip){
        repr(i, sh, th){
            if(calc(sh, i, sw, tw) != straw && calc(sh, i, sw, tw) != 0){
                rec(sh, i, sw, tw);
                rec(i+1, th, sw, tw);
                break;
            }
        }
    }
}

void solve(){
    repr(i, 1, H+1) repr(j, 1, W+1){
        if(fi[i][j] == '#') yoko[i][j] = yoko[i][j-1] + 1;
        else yoko[i][j] = yoko[i][j-1];
    }
    repr(j, 1, W+1) repr(i, 1, H+1){
        if(fi[i][j] == '#') tate[i][j] = tate[i-1][j] + 1;
        else tate[i][j] = tate[i-1][j];
    }
    repr(i, 1, H+1) repr(j, 1, W+1){
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + (fi[i][j] == '#');
    }

    rec(1, H, 1, W);
}

void output(){
    repr(i, 1, H+1){
        repr(j, 1, W+1){
            if(j > 1) cout << ' ';
            cout << ans[i][j];
        }
        cout << endl;
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    input();
    solve();
    output();

    return 0;
}

Measured memory_bytes: 2688