//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int h, w, k;
char c[300][300];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h>>w>>k;
    vector<int> check;
    for (int i = 0; i < h; i++)
    {
        bool ch=false;
        for(int j=0;j<w;j++){
            cin>>c[i][j];
            if(c[i][j]=='#') ch=true;
        }
        if(!ch){
            check.push_back(i);
        }
    }
    check.push_back(300);
    int count=1;
    int ans[h][w];
    int k=0;
    for(int i=0;i<h;i++){
        if(check[k]==i){
            k++;
            continue;
        }
            for(int j=0;j<w;j++){
                if(c[i][j]=='#'){
                    ans[i][j]=count;
                    count++;
                }
                else{
                    ans[i][j]=count;
                    if(j==w-1)
                    count++;
                }
            }
            if(c[i][w-1]=='.'){
            for(int j=w-1;j>=1;j--){
                ans[i][j]--;
                if(ans[i][j]==ans[i][j-1]) break;
            }
            count--;
            }
    }
    for(int i=0;i<check.size()-1;i++){
        if(check[i]==h-1){
            for(int j=0;j<w;j++){
                ans[h-1][j]=ans[h-2][j];
            }
        }
        else{
            for(int j=0;j<w;j++){
                ans[check[i]][j]=ans[check[i]+1][j];
            }
        }
    }
    for(int i=check.size()-2;i>=0;i--){
        if(check[i]==h-1){
            for(int j=0;j<w;j++){
                ans[h-1][j]=ans[h-2][j];
            }
        }
        else{
            for(int j=0;j<w;j++){
                ans[check[i]][j]=ans[check[i]+1][j];
            }
        }
    }
    for(int i=0;i<check.size()-1;i++){
        if(check[i]==0){
            for(int j=0;j<w;j++){
                ans[0][j]=ans[1][j];
            }
        }
        else{
            for(int j=0;j<w;j++){
                ans[check[i]][j]=ans[check[i]-1][j];
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        for(int j=0;j<w;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }
}



Measured memory_bytes: 1280