import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "B", long, "W");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long h, w, k, cnt;
    scan(h, w, k);
    auto cake = new string[](h);
    foreach (ref e; cake)
        e = sread();

    auto blocks = new long[][](h, w);
    blocks.each!((ref e) => e[] = -1);
    auto nostr = new bool[](h);

    foreach (i; iota(h))
    {
        if (cake[i].canFind('#'))
        {
            // 埋める処理
            long prev, next;
            while ((next = cake[i][prev .. $].countUntil('#')) >= 0)
            {
                foreach (j; iota(prev, prev + next + 1))
                    blocks[i][j] = cnt;

                prev += next + 1;
                cnt++;
            }

            foreach (j; iota(prev, w))
                blocks[i][j] = cnt - 1;
        }
        else
        {
            nostr[i] = true;
        }
    }

    foreach (i; iota(h))
    {
        if (nostr[i])
        {
            long nearFind()
            {
                long offset;
                while (1)
                {
                    if (i - offset >= 0 && !nostr[i - offset])
                    {
                        return i - offset;
                    }
                    if (i + offset < h && !nostr[i + offset])
                    {
                        return i + offset;
                    }
                    offset++;
                }
            }

            blocks[nearFind()].aryWrite();
        }
        else
        {
            blocks[i].aryWrite();
        }
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void aryWrite(T = long)(T[] ary)
{
    ary.map!(x => x.text()).join(' ').writeln();
}
