#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};

using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     
     int n,m,k;
     cin>>n>>m>>k;
     int a[n+1][m+1];
     memset(a,0,sizeof(a));
     int p=1;
     
     for(int i=0;i<n;i++)
        {
            string s;
            cin>>s;
            for(int j=0;j<m;j++)
                {
                    if(s[j]=='#')
                        a[i][j]=p++;
                }
        }
    
    
    for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)    
            {
                
                    if(a[i][j]!=0)
                        {
                            int p=i-1;
                            while(p>=0 && a[p][j]==0)    
                            {
                                a[p][j]=a[i][j];
                                p--;
                            }
                             p=i+1;
                             while(p<n && a[p][j]==0)
                             {
                                 a[p][j]=a[i][j];
                                 p++;
                             }
                            
                        }
            }
            
        }
     for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)    
            {
                
                    if(a[i][j]!=0)
                        {
                            int p=j-1;
                            while(p>=0 && a[i][p]==0)    
                            {
                                a[i][p]=a[i][j];
                                p--;
                            }
                             p=j+1;
                             while(p<m && a[i][p]==0)
                             {
                                 a[i][p]=a[i][j];
                                 p++;
                             }
                            
                        }
            }
            
        }
    for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cout<<a[i][j]<<" ";
            }
            cout<<endl;
        }
    
     
     
     
}


Measured memory_bytes: 1152