// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long H, W, K;
    scan(H, W, K);
    auto S = new string[](H);
    foreach (i; 0 .. H)
        S[i] = sread();
    auto ans = new long[][](H, W);
    foreach (y; 0 .. H)
        ans[y][] = -1;
    auto cnt = new long[](H);
    long id = 1;
    foreach (y; 0 .. H)
        foreach (x; 0 .. W)
            if (S[y][x] == '#')
                cnt[y]++;
    foreach (y; 0 .. H)
        if (cnt[y] != 0)
        {
            foreach (x; 0 .. W)
            {
                if (S[y][x] == '#')
                {
                    ans[y][x] = id++;
                }
            }
            foreach (x; 0 .. W - 1)
            {
                if (ans[y][x] != -1 && ans[y][x + 1] == -1)
                {
                    ans[y][x + 1] = ans[y][x];
                }
            }
            foreach_reverse (x; 1 .. W)
            {
                if (ans[y][x] != -1 && ans[y][x - 1] == -1)
                {
                    ans[y][x - 1] = ans[y][x];
                }
            }
        }
    foreach (x; 0 .. W)
    {
        foreach (y; 0 .. H - 1)
        {
            if (ans[y][x] != -1 && ans[y + 1][x] == -1)
            {
                ans[y + 1][x] = ans[y][x];
            }
        }
        foreach_reverse (y; 1 .. H)
        {
            if (ans[y][x] != -1 && ans[y - 1][x] == -1)
            {
                ans[y - 1][x] = ans[y][x];
            }
        }
    }
    foreach (a; ans)
    {
        arywrite(a);
    }
}
