#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<Int, Int>;
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

template <class T> std::ostream& print(std::ostream& out, T const& val) { return (out << val << " "); }
template <class T1, class T2> std::ostream& print(std::ostream& out, std::pair<T1, T2> const& val) {
    return (out << "{" << val.first << " " << val.second << "} ");
}
template <template <class, class...> class TT, class... Args>
std::ostream& operator<<(std::ostream& out, TT<Args...> const& cont) {
    for (auto&& elem : cont) print(out, elem);
    return out;
}

void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) {
    cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...);
}
#ifdef _MY_DEBUG
#define dump(...)                                                                                                    \
    cerr << "/* " << #__VA_ARGS__ << " [" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), \
        cerr << "*/\n\n";
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: CREATED_TIMESTAMP
 **/

template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

signed main() {
    Int H, W, K;
    cin >> H >> W >> K;
    auto t = make_vec<bool>(H, W, 0);
    auto acc = make_vec<Int>(H + 1, W + 1, 0);
    REP(i, H) {
        REP(j, W) {
            char c;
            cin >> c;
            t[i][j] = c == '#';
            acc[i + 1][j + 1] = acc[i + 1][j] + acc[i][j + 1] - acc[i][j] + t[i][j];
        }
    }
    auto calc = [&acc](Int i1, Int j1, Int i2, Int j2) -> Int {
        return acc[i2][j2] - acc[i1][j2] - acc[i2][j1] + acc[i1][j1];
    };
    using block = pair<ii, ii>;
    vector<block> bs;
    queue<block> q;
    q.push({{0, 0}, {H - 1, W - 1}});
    while (!q.empty()) {
        block b = q.front();
        q.pop();
        if (calc(b.fi.fi, b.fi.se, b.se.fi + 1, b.se.se + 1) == 1) {
            bs.push_back(b);
            continue;
        }
        bool ok = false;
        REPI(i, b.fi.fi, b.se.fi) {
            ii p1 = b.fi, p2 = {i, b.se.se};
            ii p3 = {i + 1, b.fi.se}, p4 = b.se;
            if (calc(p1.fi, p1.se, p2.fi + 1, p2.se + 1) && calc(p3.fi, p3.se, p4.fi + 1, p4.se + 1)) {
                q.push({p1, p2});
                q.push({p3, p4});
                ok = true;
                break;
            }
        }
        if (ok) continue;
        REPI(j, b.fi.se, b.se.se) {
            ii p1 = b.fi, p2 = {b.se.fi, j};
            ii p3 = {b.fi.fi, j + 1}, p4 = b.se;
            if (calc(p1.fi, p1.se, p2.fi + 1, p2.se + 1) && calc(p3.fi, p3.se, p4.fi + 1, p4.se + 1)) {
                q.push({p1, p2});
                q.push({p3, p4});
                ok = true;
                break;
            }
        }
        if (ok) continue;
        assert(0);
    }

    auto ans = make_vec<Int>(H, W, -1);
    REP(k, bs.size()) {
        auto& b = bs[k];
        REPI(i, b.fi.fi, b.se.fi + 1) {
            REPI(j, b.fi.se, b.se.se + 1) { ans[i][j] = k; }
        }
    }
    REP(i, H) {
        REP(j, W) { cout << ans[i][j] + 1 << " "; }
        cout << endl;
    }
}


Measured memory_bytes: 7280