#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
ll mod = 998244353ll;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

string multiply(string num1, string num2) 
{ 
    int len1 = num1.size(); 
    int len2 = num2.size(); 
    if (len1 == 0 || len2 == 0) 
    return "0"; 
  
    // will keep the result number in vector 
    // in reverse order 
    vector<int> result(len1 + len2, 0); 
  
    // Below two indexes are used to find positions 
    // in result.  
    int i_n1 = 0;  
    int i_n2 = 0;  
      
    // Go from right to left in num1 
    for (int i=len1-1; i>=0; i--) 
    { 
        int carry = 0; 
        int n1 = num1[i] - '0'; 
  
        // To shift position to left after every 
        // multiplication of a digit in num2 
        i_n2 = 0;  
          
        // Go from right to left in num2              
        for (int j=len2-1; j>=0; j--) 
        { 
            // Take current digit of second number 
            int n2 = num2[j] - '0'; 
  
            // Multiply with current digit of first number 
            // and add result to previously stored result 
            // at current position.  
            int sum = n1*n2 + result[i_n1 + i_n2] + carry; 
  
            // Carry for next iteration 
            carry = sum/10; 
  
            // Store result 
            result[i_n1 + i_n2] = sum % 10; 
  
            i_n2++; 
        } 
  
        // store carry in next cell 
        if (carry > 0) 
            result[i_n1 + i_n2] += carry; 
  
        // To shift position to left after every 
        // multiplication of a digit in num1. 
        i_n1++; 
    } 
  
    // ignore '0's from the right 
    int i = result.size() - 1; 
    while (i>=0 && result[i] == 0) 
    i--; 
  
    // If all were '0's - means either both or 
    // one of num1 or num2 were '0' 
    if (i == -1) 
    return "0"; 
  
    // generate the result string 
    string s = ""; 
      
    while (i >= 0) 
        s += std::to_string(result[i--]); 
  
    return s; 
} 

int isGreaterOrEqualTo(string s1, string s2){
    if(s1.size() < s2.size()) return 0;
    if(s1.size() > s2.size()) return 1;
    return s1 >= s2;
}
  
int vis[310][310];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector <string> vec(n);
    int cnt = 0;
    map <int,vector <pair<int,int> > > mp;
    for(int i = 0; i < n; i++){
        cin >> vec[i];
        for(int j = 0; j < m; j++){
            if(vec[i][j] == '#'){
                cnt++;
                vis[i][j] = cnt;
                //cout << j << "|"<< endl;
                mp[j].push_back({i, cnt});
            }
        }
    }
    for(int j = 0; j < m; j++){
        if(mp.count(j)){
            int ind = 0;
            for(int i = 0; i < mp[j].size(); i++){
                while(ind <= mp[j][i].first){
                      vis[ind][j] = mp[j][i].second;
                      ind++;
                }
                if(i == mp[j].size()-1){
                   while(ind < n){
                         vis[ind][j] = mp[j][i].second;
                         ind++;
                   }
                }
            }
        }
    }
    for(int j = 0; j < m; j++){
        //cout << j << " " << mp.count(j) << endl;
        if(mp.count(j)) continue;
        //cout << j << " ||" << endl;
        int val;
        if(mp.lower_bound(j) == mp.end()) val = (*mp.rbegin()).first;
        else val = (*mp.lower_bound(j)).first;
        //cout << j << " " << val << endl;
        if(j < val){
           while(j < val){
                 for(int i = 0; i < n; i++){
                     vis[i][j] = vis[i][val];
                 }
                 j++;
           }
        } else{
            while(j < m){
                 for(int i = 0; i < n; i++){
                     vis[i][j] = vis[i][val];
                 }
                 j++;
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++) cout << vis[i][j] << " ";
        cout << endl;
    }
   
}
 


Measured memory_bytes: 2688