#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cassert>

#include<cmath>
#include<functional>
#include<algorithm>

#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<bitset>
#include<tuple>

#define TEST {IS_TEST=true;}

using namespace std;
using ll = int_fast64_t;
using v_bool = vector <bool>;
using v_ll = vector <ll>;
using v_std = vector <string>;
using p_ll = pair <ll,ll>;
using vv_ll = vector <vector <ll> >;
using vp_ll = vector < p_ll >;

using ld = long double;
using v_ld = vector <ld>;
using vv_ld = vector<v_ld>;

bool IS_TEST=false;
ll ll_min=1LL<<63;
ll ll_max=~ll_min;
ll int_min=1LL<<31;
ll int_max=~ll_max;
ll MOD = 1000000007;

template<class T>
void show(const T &x){
  if (!IS_TEST) return;
  cout << x << endl;
}
template<class T1,class T2>
void show(const pair<T1,T2> &x){
  if (!IS_TEST) return;
  cout << "{" << x.first << "," << x.second << "}" << endl;
}

template<class T>
void show_sub(const T &x){if (!IS_TEST) return; cout << x;}
void show_sub(const string &x){if (!IS_TEST) return; cout << x << endl;}
template<class T1,class T2>
void show_sub(const pair<T1,T2> &x){
  if (!IS_TEST) return;
  cout << "{" << show_sub(x.first) << "," << show_sub(x.second) << "}";
}
template<class T>
void v_show(const T &v){
  if (!IS_TEST) return;
  auto itr=v.begin();
  while(itr!=v.end()){ show_sub(*itr); itr++;}
  cout << endl;
}

template<class T>
void vv_show(const T &v){
  if (!IS_TEST) return;
  cout << "--------------------------------\n";
  auto itr=v.begin();
  while(itr!=v.end()){ v_show(*itr); itr++;}
  cout << "--------------------------------" << endl;
}



ll max(ll x,ll y){return x>y?x:y;}
ll max(ll x,ll y, ll z){return max(max(x,y),z);}
ll max(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) {ans=max(ans,*b);b++;}
    return ans;
}
ll min(ll x,ll y){return x<y?x:y;}
ll min(ll x,ll y, ll z){return min(min(x,y),z);}
ll min(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) {ans=min(ans,*b);b++;}
    return ans;
}
ll mid(ll x,ll y,ll z){
    if (y>=x && x>=z) return x;
    if (z>=x && x>=y) return x;
    if (x>=y && y>=z) return y;
    if (z>=y && y>=x) return y;
    if (x>=z && z>=y) return z;
    if (y>=z && z>=x) return z;
    return x;
}
ll gcd(ll x,ll y){
    if(x<0)x=-x; if(y<0)y=-y;
    while(y>0){ x%=y; swap(x,y); }
    return x;
}
ll gcd(ll x,ll y, ll z){return gcd(gcd(x,y),z);}
ll gcd(v_ll::iterator b,v_ll::iterator e){
    ll ans=0;
    while (b<e) ans=gcd(ans,*b);
    return ans;
}
ll lcm(ll x,ll y){
    ll z=x*y; if(x<0)x=-x; if(y<0)y=-y;
    while(y>0){ x%=y; swap(x,y); }
    return z/x;
}
ll lcm(ll x,ll y, ll z){return lcm(lcm(x,y),z);}
ll lcm(v_ll::iterator b,v_ll::iterator e){
    ll ans=1;
    while (b<e) ans=lcm(ans,*b);
    return ans;
}

v_ll arange(ll n){
    v_ll v(n+1,0);
    for(ll i=0;i<=n;i++)v[i]=i;
    return v;
}

ll vec_sum(const v_ll& v,ll b,ll e){
    ll ans=0;
    for(ll i=b;i<e;i++)ans+=v[i];
    return ans;
}
ll v_sum(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) { ans+=*b; b++;}
    return ans;
}
ll v_xor(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) { ans^=*b; b++;}
    return ans;
}
ll v_eq(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) { ans^=~*b; b++;}
    return ans;
}


template<class T> void refl_max(T& x,const T& y){ if (x>=y) return; x=y; }
template<class T> void refl_min(T& x,const T& y){ if (x<=y) return; x=y; }

template<class T,class S> void refl_max(T& x,S& xx,const T& y,const S& yy){
  if (x>=y) return; x=y; xx=yy;
}
template<class T,class S> void refl_min(T& x,S& xx,const T& y,const S& yy){
  if (x<=y) return; x=y; xx=yy;
}

template<class T> void quit(T x){cout << x << endl; exit(0);}

/*O(logN)*/
ll sqrt_ll(ll n){
  assert(n>=0);
  ll ok = 0,ng = n+1;
  while(ok-ng>1||ng-ok>1){ ll m=(ok+ng)/2; if (m*m<=n) ok=m; else ng=m;}
  return ok;
}

ll H,W,K;
vector<string> S;
vv_ll A;
v_ll rows;
v_ll rowgrp;
int main(){
  cin >> H >> W >> K;
  S.assign(H+10,"");
  A.assign(H+10,v_ll(W+10,0));
  rows.assign(H+10,0);
  rowgrp.assign(H+10,0);
  for (ll i=0;i<H;i++){
    cin >> S[i];
  }
  for (ll i=0;i<H;i++){
    for (ll j=0;j<W;j++){
      if (S[i][j]=='#') rows[i]++;
    }
  }
  ll idxtemp=-1;
  for (ll i=0;i<H;i++){
    if (rows[i]>0) idxtemp++;
    rowgrp[i]=max(idxtemp,0);
  }
  ll idx=1;
  for (ll i=0;i<H;i++){
    if (rows[i]==0) continue;
    v_ll colgrp(W+10,0);
    ll idxcols=-1;
    for (ll j=0;j<W;j++){
      if (S[i][j]=='#') idxcols++;
      colgrp[j]=max(idxcols,0);
    }
    for (ll i2=0;i2<H;i2++){
      for (ll j2=0;j2<W;j2++){
        if (rowgrp[i]==rowgrp[i2]){
          A[i2][j2]=idx+colgrp[j2];
        }
      }
    }
    idx+=idxcols+1;;
  }
  for (ll i=0;i<H;i++){
    for (ll j=0;j<W;j++){
      if (j>0) cout << " ";
      cout << A[i][j];
    }
    cout << endl;
  }
}




Measured memory_bytes: 1664