#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int H, W, K; cin >> H >> W >> K;
    vector<string> S(H); for (auto &s : S) cin >> s;
    string str;
    int first = 0;
    int id = 0;
    for (int i = 0; i < H; i++) {
        int cnt = 0;
        for (int j = 0; j < W; j++) { if (S[i][j] == '#') cnt++; }
        if (cnt == 0 && str.empty()) {
            first++;
        } else if (cnt == 0) {
            cout << str << '\n';
        } else {
            str = "";
            id++;
            int f = 0;
            for (int j = 0; j < W; j++) {
                if (S[i][j] == '#' && f == 0) f++;
                else if (S[i][j] == '#') id++;
                str += to_string(id) + ' ';
            }
            for (int j = 0; j < first; j++) cout << str << '\n';
            cout << str << '\n';
            first = 0;
        }
    }
    return 0;
}