#include <bits/stdc++.h>
using namespace std;

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

template<class T> struct Grid {
    vector<T> data;
    const size_t h, w;
    Grid(size_t h, size_t w, T v = T()) : data(h * w, v), h(h), w(w) {}
    T& operator()(size_t i, size_t j) { return data[i * w + j]; }
    auto adjacent_indexes(size_t i, size_t j) const {
        vector<pair<size_t, size_t>> vs;
        if (i > 0) vs.emplace_back(i - 1, j);
        if (j > 0) vs.emplace_back(i, j - 1);
        if (i + 1 < h) vs.emplace_back(i + 1, j);
        if (j + 1 < w) vs.emplace_back(i, j + 1);
        return vs;
    }
    friend istream& operator>>(istream& in, Grid& g) {
        for (auto& v : g.data) in >> v;
        return in;
    }
    friend ostream& operator<<(ostream& out, const Grid& g) {
        for (size_t i = 0; i < g.h; ++i) {
            cout << g.data[i * g.w];
            for (size_t j = 1; j < g.w; ++j) {
                out << " " << g.data[i * g.w + j];
            }
            out << "\n";
        }
        return out;
    }
};

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    Grid<char> s(h, w);
    cin >> s;
    Grid<int> ans(h, w);
    int color = 1;
    auto fill_line = [&](int i) {
        int last = -1;
        for (int j = 0; j < w; j++) {
            ans(i, j) = color;
            if (s(i, j) == '#') {
                last = j;
                color++;
            }
        }
        if (last == -1) {
            return false;
        }
        for (int j = last + 1; j < w; j++) {
            ans(i, j) = color - 1;
        }
        return true;
    };
    int filled = [&]() {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s(i, j) == '#') {
                    return i;
                }
            }
        }
        return 0;
    }();
    fill_line(filled);
    for (int i = filled-1; i >= 0; i--) {
        if (!fill_line(i)) {
            for (int j = 0; j < w; j++) {
                ans(i, j) = ans(i+1, j);
            }
        }
    }
    for (int i = filled+1; i < h; i++) {
        if (!fill_line(i)) {
            for (int j = 0; j < w; j++) {
                ans(i, j) = ans(i-1, j);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 1280