#include <iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
int itigocount(string hoge){
    int p = 0;
    rep(i,hoge.size()) if(hoge[i]=='#') p++;
    return p;
}
int itigostart(int asum[],int h){
    rep(i,h){
        if(asum[i]!=0) return i-1;
    }
    return -1;
}
int itigoend(int asum[],int h,int k){
    rep(i,h+1){
        if(asum[i]==k) return i-1;
    }
    return -1;
}
int main(){
    int h,w,k;
    cin >> h >> w >> k;
    char cake[h][w];
    int asum[h+1];
    asum[0] = 0;
    rep(i,h){
        string hoge;
        cin >> hoge;
        asum[i+1]=asum[i]+itigocount(hoge);
        rep(j,w){
            cake[i][j] = hoge[j];
        }
    }
    int start = itigostart(asum,h);
    int end = itigoend(asum,h,k);
    int point = 1;
    int ans[h][w];
    //cout << start << " " << end << endl;
    if(start>=end || start==-1){
        int meu = 0;
        rep(i,w){
            if(cake[end][i]=='#'){
                meu++;
                rep(j,h){
                    ans[j][i] = point;
                }
                point++;
                if(k==meu) point--;
            }
            else{
                rep(j,h){
                    ans[j][i] = point;
                }
            }
        }
        rep(i,h){
            rep(j,w){
                cout << ans[i][j] << " ";
            }
            cout << endl;
        }
        return 0;   
    }
    for(int i = start;i <= end;i++){
        int meu = 0;
        int itigonum = asum[i+1]-asum[i];
        //cout << itigonum << endl;
        int tmp;
        for(int j = i;j<h;j++){
            if(asum[i+1]!=asum[j+1]){
                tmp = j;
                break;
            }
        }
        if(i==start){
            rep(j,w){
                if(cake[i][j]=='#'){
                    meu++;
                    rep(k,tmp){
                        ans[k][j]=point;
                    }
                    point++;
                    if(itigonum==meu) point--;
                }
                else{
                    rep(k,tmp){
                        ans[k][j]=point;
                    }
                }
            }
            point++;
            i = tmp-1;
        }
        else if(i == end){
            rep(j,w){
                if(cake[i][j]=='#'){
                    meu++;
                    for(int k = end;k<h;k++){
                        ans[k][j]=point;
                    }
                    point++;
                    if(itigonum==meu) point--;
                }
                else{
                    for(int k = end;k<h;k++){
                        ans[k][j]=point;
                    }
                }
            }            
        }
        else{
            rep(j,w){
                if(cake[i][j]=='#'){
                    meu++;
                    for(int k = i;k<tmp;k++){
                        ans[k][j] = point;
                    }
                    point++;
                    if(itigonum==meu) point--;
                }
                else{
                    for(int k = i;k<tmp;k++){
                        ans[k][j] = point;
                    }
                }
            }   
            point++;  
            i = tmp-1;
        }
    }
    rep(i,h){
        rep(j,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152