#include <iostream>
#include <vector>
#include <queue> //priority queue
#include <stack>
#include <map> // multimap
#include <set> //multiset
#include <list> 
#include <utility> // pair
#include <iterator>
#include <deque> // insertion as both ends
#include <string>
// g1=s.substr(0,n/2);
// g2=s.substr(n/2+n%2,n/2);
#include <cctype> //isaplha
#include <iomanip>      // std::setprecision
#include <algorithm> //binary_search,sort, next_permutation in lexicographically greater permutation, fill(it1,it2,val)
#include <cmath>
#include <limits.h> //INT_MIN,INT_MAX
#include <numeric>  //iota,partial_sum,inner_product,accumulate(begin,end,num)
#include <functional>  //Arithmetic, comparators, logical
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h> 
#include <cstring>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define pi 3.14159
#define mod 1000000007

#define ll long long 
#define ull unsigned long long
#define pb push_back
#define pf push_front //deque
#define mp make_pair
#define PQ priority_queue

#define f first
#define s second
#define pii pair< int, int >
#define piii pair<int,pair<int,int> >
#define vi vector<int> 
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = s; 
    for (int i=1; i<n;i++) 
        s += s1;
    return s; 
}
string getString(char x) {
    string s(1, x); 
    return s;    
} 

void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
}

vector<ll> primeFactors(ll n)  { 
    vector<ll> v;
    if(n%2==0) v.pb(2); 
    while (n % 2 == 0)  {  
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2) {  
        if(n%i==0) v.pb(i);
        while (n % i == 0) {  
            n = n/i;  
        }  
    } 
    if (n > 2)  v.pb(n);
    return v;
}  
bool isPrime(ll n){
    if (n <= 1)  return false; 
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

int main(){
    optimizeIO();
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char> > v(h,vector<char> (w,0));
    rep(i,0,h)rep(j,0,w) cin>>v[i][j];
    vector<vector<int> > ans(h,vector<int> (w,0));
    std::vector<int> v1;
    int fill=1;
    int idx=0;
    rep(i,0,h){
        int flag=0;
        rep(j,0,w){
            if(v[i][j]=='#') flag=1;
        }
        if(flag==0){
            v1.pb(i);
            continue;
        }
        else{
            vi x;
            rep(j,0,w){
                if(v[i][j]=='#') x.pb(j);
            }
            rep(j,0,x[x.size()-1]+1){
                ans[i][j]=fill;
                if(v[i][j]=='#') fill++;
            }
            rep(j,x[x.size()-1]+1,w) ans[i][j]=fill-1;
            idx=i;
        }
        if(v1.size()!=0){
            rep(j,0,v1.size()){
                ans[v1[j]]=ans[i];
            }
            v1.clear();
        }
    }
    if(v1.size()!=0){
            rep(j,0,v1.size()){
                ans[v1[j]]=ans[idx];
            }
            v1.clear();
    }
    rep(i,0,h){ rep(j,0,w) cout<<ans[i][j]<<" "; cout<<endl;}
}



Measured memory_bytes: 1280