#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
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; }

#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 

 
LL modpow(LL a, LL n, LL mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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;
}

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}


void func() {
  LL H;
  cin >> H;
  LL W;
  cin >> W;
  LL K;
  cin >> K;
  
  VVLL S(H,VLL(W,0));
  
  VLL X;
  VLL Y;

  LL a = 1;
  REP(i,H){
    REP(j,W){
      char c;
      cin >> c;
      if(c=='.'){
        S[i][j]=0;
      }
      else{
        S[i][j]=a;
        X.push_back(j);
        Y.push_back(i);
        a ++;
      }
    }
  }

  //cerr << X.size() << endl;;
  //cerr << Y.size() << endl;;
  
  REP(k ,K){
    REP(i,H){
      //PRINTSP(S[i]);
    }
    //cerr << endl;
    LL xl = X[k];
    LL y = Y[k];
    //left
    while(true){
      xl--;
      if(xl>=0 && S[y][xl]==0){
        S[y][xl]=(k+1);
      }
      else{
        break;
      }
    }
    xl++;

    LL xr = X[k];
    y = Y[k];
    //right
    while(true){
      xr++;
      if(xr<W && S[y][xr]==0){
        S[y][xr]=(k+1);
      }
      else{
        break;
      }
    }
    xr--;

    LL yu = Y[k];
    //up
    while(true){
      //cerr << xl << " " << xr << " " << yu << endl;
      yu--;
      if(yu<0){
        break;
      }
      else{
        bool isOK=true;
        for(LL x =xl; x<=xr; x++){
          if(S[yu][x]!=0){
            isOK = false;
            break;
          }
        }
        if(isOK){
          for(LL x =xl; x<=xr; x++){
            S[yu][x]=(k+1);
          }
        }
        else{
          break;
        }
      }
    }

    LL yd = Y[k];
    //up
    while(true){
      yd++;
      if(yd>=H){
        break;
      }
      else{
        bool isOK=true;
        for(LL x =xl; x<=xr; x++){
          if(S[yd][x]!=0){
            isOK = false;
            break;
          }
        }
        if(isOK){
          for(LL x =xl; x<=xr; x++){
            S[yd][x]=(k+1);
          }
        }
        else{
          break;
        }
      }
    }
  }



  VVLL I(H,VLL(W,0));
  REP(i,H){
    REP(j,W){
    }
  }


  REP(i,H){
    for(auto s : S[i]){
      cout << s <<" " ;
    }
    cout << endl;
    //PRINTSP(S[i]);
  }
  return;
}

int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 3564