#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
ll bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
char A[3001][3001];
ll color[401][401];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
 ll n,m,k,cnt=0;
 cin>>n>>m>>k;
 for(int i=0;i<n;i++)
 {
     for(int j=0;j<m;j++)
     {
         cin>>A[i][j];
     }
 }
 for(int i=0;i<n;i++)
 {
     for(int j=0;j<m;j++)
     {
         if(A[i][j]=='#')
            color[i][j]=++cnt;
     }
 }
 for(int i=0;i<n;i++)
 {
     for(int j=0;j<m;j++)
     {
         if(color[i][j]>0)
         {
             ll p=j+1;
             while(color[i][p]==0&&p<m)
             {
                 color[i][p]=color[i][j];
                 p++;
             }
             p=j-1;
             while(color[i][p]==0&&p>=0)
             {
                 color[i][p]=color[i][j];
                 p--;
             }
         }
     }
 }
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<m;j++)
         {
             if(color[i][j]>0)
             {
                ll p=i+1;
                while(color[p][j]==0&&p<n)
                {
                    color[p][j]=color[i][j];
                    p++;
                }
                p=i-1;
                while(color[p][j]==0&&p>=0)
                {
                    color[p][j]=color[i][j];
                    p--;
                }
             }
         }
     }
 for(int i=0;i<n;i++)
 {
     for(int j=0;j<m;j++)
     {
         cout<<color[i][j];
         if(j==m-1)
            cout<<endl;
         else
            cout<<" ";
     }
 }
return 0;
}



Measured memory_bytes: 6656