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];
    // writeln(count(0, 0, 2, 2));
    long x;
    auto completed = new bool[](W);
    long completed_cnt;
    long id = 1;
    auto ans = new long[][](H, W);
    while (true)
    {
        if (completed[x])
        {
            x = (x + 1) % W;
            continue;
        }
        long y = -1;
        inner_foreach: foreach (i; 0 .. H)
            if (ans[i][x] == 0)
            {
                y = i;
                break inner_foreach;
            }
        if (y == -1)
        {
            completed[x] = true;
            completed_cnt++;
            x = (x + 1) % W;
            if (completed_cnt == W)
            {
                foreach (h; 0 .. H)
                {
                    foreach (w; 0 .. W)
                    {
                        write(ans[h][w], " ");
                    }
                    writeln();
                }
                return;
            }
            continue;
        }
        long h = 1;
        long w = 1;
        inner_while: while (true)
        {
            if (y + h < H && x + w < W && count(y, x, h + 1, w + 1) <= 1)
            {
                h++;
                w++;
            }
            else if (y + h < H && count(y, x, h + 1, w) <= 1)
            {
                h++;
            }
            else if (x + w < W && count(y, x, h, w + 1) <= 1)
            {
                w++;
            }
            else
            {
                // writefln("%d %d %d %d", x, y, w, h);
                foreach (hh; 0 .. h)
                    foreach (ww; 0 .. w)
                        ans[y + hh][x + ww] = id;
                // writeln(progress);
                x = (x + 1) % W;
                id++;
                break inner_while;
            }
        }
    }
}
