#include <bits/stdc++.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int h, w, k;
    cin >> h >> w >> k;
    
    char cake[h][w];

    irep(i, h) {
        irep(j, w) {
            cin >> cake[i][j];
        }
    }
    
    int cnt = 1;
    int ans[h][w];
    v_int prev;

    irep(i, h) {
        bool ichigo = false;
        irep(j, w) {
            if(cake[i][j] == '#') {
                ichigo = true;
            }
        }
        if(ichigo) {
            int j = 0;
            while(cake[i][j] == '.') {
                ans[i][j] = cnt; 
                j++;    
            }
            
            while(j<w) {
                ans[i][j] = cnt;
                j++;
                while(j < w && cake[i][j] == '.') {
                    ans[i][j] = cnt;
                    j++;
                }
                cnt++;
            }
            
            if(prev.size()) {
                irep(col, w) {
                    irep(row, prev.size()) {
                        ans[prev[row]][col] = ans[i][col];
                    }
                }
                prev.erase(prev.begin(), prev.end());
            }
        } else {
            prev.push_back(i);
        }
    }
    
    if(prev.size()) {
        int row = prev.front() - 1;
        for(auto p : prev) {
            irep(j, w) {
                ans[p][j] = ans[row][j];
            }
        }
    }

    irep(i, h) {
        irep(j, w) {
            if(j < w-1) {
                printf("%d ", ans[i][j]);
            } else {
                printf("%d\n", ans[i][j]);
            }
        } 
    }
    return 0;
}


/*atcoder*/


Measured memory_bytes: 4132