//https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_b

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (998244353)
#define INF (ll(1e18))

class SegmentTree {
public:
    int N, n;
    vector<ll> value;
    SegmentTree(int n) {
        this->n = n;
        this->N = 1;
        while (N < n) N *= 2;
        this->value = vector<ll>(2 * N - 1, INF);
    }
    
    void update(int i, ll x) {
        i += N - 1;
        value[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            value[i] = min(value[i * 2 + 1], value[i * 2 + 2]);
        }
    }
    
    ll query(int l, int r) {
        return _query(l, r, 0, 0, N);
    }
    
    ll _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b)
            return value[k];
        else {
            ll c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(c1, c2);
        }
    }
};

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    REP(i, H) {
        cin >> s[i];
    }
    
    ll k = 0;
    vector<vector<ll>> res(H, vector<ll>(W, 0));
    REP(h, H) {
        ll cnt = 0;
        REP(w, W) {
            if (s[h][w] == '#') {
                cnt++;
            }
        }
        
        if (cnt > 0) {
            k++;
            ll c = 0;
            REP(w, W) {
                if (s[h][w] == '#' && c == 0) {
                    c++;
                }else if (s[h][w] == '#' && c < cnt) {
                    k++;
                    c++;
                }
                res[h][w] = k;
                assert(k <= K);
            }
        }
    }
    
    REP(hh, H-1) {
        ll h = hh+1;
        REP(w, W) {
            if (res[h][w] == 0) {
                res[h][w] = res[h-1][w];
            }
        }
    }
    REP(hh, H-1) {
        ll h = H-hh-2;
        REP(w, W) {
            if (res[h][w] == 0 && h != H-1) {
                res[h][w] = res[h+1][w];
            }
        }
    }
    
    REP(h, H) {
        REP(w, W) {
            cout << res[h][w] << " ";
        }
        cout << endl;
    }
}

/*
4 3 5
...
###
#.#
...
 
 */


Measured memory_bytes: 1664