void main() {
    int[] tmp = readln.split.to!(int[]);
    int h = tmp[0], w = tmp[1], k = tmp[2];

    int[][] field = new int[][](h, w);
    int cnt;
    int row;
    foreach (i; 0 .. h) {
        string s = readln.chomp;
        if (s.canFind('#')) {
            int col;
            foreach (j, x; s) {
                if (x == '#') {
                    ++cnt;
                    field[i][col..j+1] = cnt;
                    col = j.to!int + 1;
                }

                if (j == w - 1) {
                    if (field[i][col..$].canFind(0)) {
                        field[i][col..$] = cnt;
                    }
                }
            }

            if (row) {
                foreach (r; 1 .. row+1) {
                    foreach (j; 0 .. w) {
                        field[i-r][j] = field[i][j];
                    }
                }
                row = 0;
            }
        } else {
            ++row;

            if (i == h - 1) {
                foreach (r; 0 .. row) {
                    foreach (j; 0 .. w) {
                        field[i-r][j] = field[i-row][j];
                    }
                }
            }
        }
    }

    foreach (x; field) {
        x.writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;