#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
//#define double long dounle

////////////////////////////////////////////////////////////////////
struct edge {
  int to, from, cost;
  edge(int to, int cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};
using edges = vector<edge>;
using graph = vector<edges>;
using matrix = vector<vector<int>>;
vector<int> dijkstra(int s, graph &g){
  vector<int> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

vector<int> bellman(int s, graph &g){
  vector<int> dist(g.size()+10, INF);dist[s] = 0;
  while(true){
    bool update = false;
    rep(i,g.size()){
      edges es = g[i];
      rep(j,es.size()){
        edge e = es[j];
        if(dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost){
          dist[e.to] = dist[e.from] + e.cost;
          update = true;
        }
      }
    }
    if(!update)break;
  }
  return dist;
}

vector<vector<int>> warshall(matrix &g){
  vector<vector<int>> dist(g.size()+10);
  rep(i,g.size()+10){
    dist[i].resize(g.size()+10);
    rep(j,g.size()+10)dist[i][j] = (g[i][j] ? g[i][j] : (i==j ? 0 : INF));
  }
  rep(k,g.size()){
    rep(i,g.size()){
      rep(j,g.size()){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  return dist;
}
////////////////////////////////////////////////////////////////////
bool s[310][310], r[310][310], emp[310];int ans[310][310];queue<P> que;
signed main(){
  int h,w,k;cin>>h>>w>>k;int ind = 1;
  rep(i,h){
    bool updated = false;
    rep(j,w){
      char c;cin>>c;s[i][j] = (c=='#' ? true : false);
      if(c=='#'){
        updated = true;que.push(P(i,j));
        ans[i][j] = ind;ind++;
      }
    }
    if(!updated)emp[i] = true;
  }
  while(!que.empty()){
    P p = que.front();que.pop();
    for(int j = p.first-1;j >= 0;j--){
      if(!emp[j] || ans[j][p.second])break;
      ans[j][p.second] = ans[p.first][p.second];
    }
    repd(j,p.first+1,h){
      if(!emp[j] || ans[j][p.second])break;
      ans[j][p.second] = ans[p.first][p.second];
    }
    for(int i = p.second-1;i >= 0;i--){
      if(ans[p.first][i])break;
      ans[p.first][i] = ans[p.first][p.second];
      for(int j = p.first-1;j >= 0;j--){
        if(!emp[j] || ans[j][i])break;
        ans[j][i] = ans[p.first][p.second];
      }
      repd(j,p.first+1,h){
        if(!emp[j] || ans[j][i])break;
        ans[j][i] = ans[p.first][p.second];
      }
    }
    repd(i,p.second+1,w){
      if(ans[p.first][i])break;
      ans[p.first][i] = ans[p.first][p.second];
      for(int j = p.first-1;j >= 0;j--){
        if(!emp[j] || ans[j][i])break;
        ans[j][i] = ans[p.first][p.second];
      }
      repd(j,p.first+1,h){
        if(!emp[j] || ans[j][i])break;
        ans[j][i] = ans[p.first][p.second];
      }
    }
  }
  rep(i,h)rep(j,w)cout << ans[i][j] << (j == w-1 ? "\n" : " ");
}



Measured memory_bytes: 2304