import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto K = s[2];
    auto A = iota(H).map!(_ => readln.chomp.map!(a => a == '#' ? 1 : 0).array).array;

    auto ans = new int[][](H, W);
    int num = 1;

    foreach (i; 0..H) {
        if (A[i].sum == 0) {
            continue;
        }
        bool flag = false;
        foreach (j; 0..W) {
            if (A[i][j] == 1) {
                if (flag) {
                    num += 1;
                } else {
                    flag = true;
                }
            }
            ans[i][j] = num;
        }
        num += 1;
    }

    bool flag = false;
    if (ans.front.sum > 0) {
        flag = true;
    }

    foreach (i; 1..H) {
        if (ans[i].sum == 0) {
            if (flag) {
                ans[i] = ans[i-1].dup;
            }
        } else {
            flag = true;
        }
    }

    flag = false;
    foreach_reverse (i; 0..H-1) {
        if (ans[i].sum == 0) {
            if (flag) {
                ans[i] = ans[i+1].dup;
            }
        } else {
            flag = true;
        }
    }

    ans.each!writeln;
}


