#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int a[310][310];
char grid[310][310];
int h,w,k;

bool check(vector<bool> flag){
    for (int i = 0; i < h; i++)
    {
        if(!flag[i]) return false;
        
    }
    return true;
}
signed main(){
    cin>>h>>w>>k;
    vector<bool>flag(h,false);    
    REP(i,h) REP(j,w) cin>>grid[i][j];
    int cnt=0;
    for (int i = 0; i < h; i++)
    {
        int piece=0;
        for (int j = 0; j < w; j++)
        {
            if(grid[i][j]=='#'){
                flag[i]=true;
                piece++;
            }
        }
        int tmp=0;
        if(flag[i])cnt++;
        for (int j = 0; j < w; j++)
        {
            if(!flag[i]) break;
            a[i][j]=cnt;
            if(grid[i][j]=='#' ){
                tmp++;
                cnt++;
            }
            if(tmp==piece && grid[i][j]=='#'){
                cnt--;
            } 

        }
    }
     //   cerr<<flag[1]<<endl;
        for (int cont = 0; cont < h; cont++)
        {
            
        
            bool ok=true;
            for (int i = 0; i < h; i++)
            {
                if(flag[i]==false) {
                    ok=false;
                  ///  cerr<<i<<endl;
                    break;
                }
                //cerr<<flag[i]<<endl;
            }
            
            if(ok){
                break;
            } 
            
            for (int i = 0; i < h; i++)
            {
                if(!flag[i]){
                    if(i+1<h){
                        if(flag[i+1]){
                    for (int j = 0; j < w; j++)
                    {
                        a[i][j]=a[i+1][j];
                    }
                     flag[i]=true;
                    }
                    }
                    if(i>=1){
                        if(!flag[i] && flag[i-1]){
                        for (int j = 0; j < w; j++)
                    {
                        a[i][j]=a[i-1][j];
                    }
                     flag[i]=true;
                    }
                    }
                }
              /*  if(!flag[h-1]){
                    if(!flag[h-2]) break;
                    for (int j = 0; j < w; j++)
                    {
                        a[h-1][j]=a[h-2][j];
                    }
                    flag[h-1]=true;
                }*/
                 

            }
            
        
        }
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                cout<<a[i][j]<<" ";
            }
            cout<<endl;
        }
        

    
        
   
    return 0;
}

Measured memory_bytes: 1536