#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {0, 0, -1, 1, 1, -1, -1, 1};
const int dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------
int H, W ;
vector<vector<int> > seen ;
vvint ans ;
char grid[10000][10000] ;

void dfs_grid(int x, int y){
    seen[x][y] = 1 ;
    for(int i=0;i<2;i++){
        int nx = x + dx[i] ;
        int ny = y + dy[i] ;

        if(0<=nx && nx<H && 0<=ny && ny<W && seen[nx][ny]==0){
            if(grid[nx][ny]=='.'){
                ans[nx][ny] = ans[x][y] ;
                dfs_grid(nx,ny) ;
            }
        }
    }
    return ;
}

void dfs_grid2(int x, int y){
    seen[x][y] = 1 ;
    for(int i=2;i<4;i++){
        int nx = x + dx[i] ;
        int ny = y + dy[i] ;

        if(0<=nx && nx<H && 0<=ny && ny<W && seen[nx][ny]==0){
            if(grid[nx][ny]=='.'){
                ans[nx][ny] = ans[x][y] ;
                dfs_grid2(nx,ny) ;
            }
        }
    }
    return ;
}
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k ;
    cin >> H >> W >> k ;

    vector<vector<int> > zero(H,vector<int>(W,0)) ;
    seen = zero ;
    ans = zero ;

    int cnt = 1 ;

    vector<string> str(H) ;
    for(int i=0;i<H;i++){
        cin >> str[i];
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            grid[i][j] = str[i][j] ;
            if(grid[i][j]=='#'){
                ans[i][j] = cnt ;
                cnt++ ;
            }
        }
    }
    
    for(int k=0;k<H;k++){
        for(int l=0;l<W;l++){
            if(seen[k][l]==0 && grid[k][l]=='#'){
                dfs_grid(k,l) ;
            }
        }
    }

    for(int k=0;k<H;k++){
        for(int l=0;l<W;l++){
            if(seen[k][l]==1){
                dfs_grid2(k,l) ;
            }
        }
    }



    REP(i,H){
        REP(j,W){
            cout << ans[i][j] <<" " ;
        }
        cout <<endl ;
    }



    return 0;
}


Measured memory_bytes: 4864