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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long H, W, K;
    scan(H, W, K);
    string[] S;
    foreach (_; 0 .. H)
        S ~= sread();
    auto st = new long[][](H + 2, W + 2);
    foreach (h; 1 .. H + 1)
    {
        foreach (w; 1 .. W + 1)
        {
            st[h][w] += (S[h - 1][w - 1] == '#');
            st[h][w + 1] = st[h][w];
        }
    }
    foreach (h; 1 .. H + 1)
    {
        st[h + 1][] += st[h][];
        // writeln(st[h]);
    }
    alias count = (long y, long x, long h, long w) => st[y + h][x + w]
        - st[y + h][x] - st[y][x + w] + st[y][x];
    alias Rect = Tuple!(long, "y", long, "x", long, "h", long, "w");

    DList!Rect Q;
    auto ans = new long[][](H, W);
    foreach (ref row; ans)
        row[] = 1;
    Q.insertBack(Rect(0, 0, H, W));
    long id = 1;
    loop_while: while (!Q.empty)
    {
        auto r = Q.back;
        Q.removeBack();
        if (1 < count(r.y, r.x, r.h, r.w))
        {
            foreach (h; 0 .. r.h)
            {
                long a = count(r.y, r.x, h, r.w);
                long b = count(r.y + h, r.x, r.h - h, r.w);
                if (0 < a && 0 < b)
                {
                    id++;
                    foreach (hh; 0 .. h)
                        foreach (ww; 0 .. r.w)
                        {
                            ans[r.y + hh][r.x + ww] = id;
                        }
                    Q.insertBack(Rect(r.y, r.x, h, r.w));
                    Q.insertBack(Rect(r.y + h, r.x, r.h - h, r.w));
                    continue loop_while;
                }
            }
            foreach (w; 0 .. r.w)
            {
                long a = count(r.y, r.x, r.h, w);
                long b = count(r.y, r.x + w, r.h, r.w - w);
                if (0 < a && 0 < b)
                {
                    id++;
                    foreach (hh; 0 .. r.h)
                        foreach (ww; 0 .. w)
                        {
                            ans[r.y + hh][r.x + ww] = id;
                        }
                    Q.insertBack(Rect(r.y, r.x, r.h, w));
                    Q.insertBack(Rect(r.y, r.x + w, r.h, r.w - w));
                    continue loop_while;
                }
            }
        }
    }
    foreach (row; ans)
        row.map!(text).join(' ').writeln();
}
