/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
5 5 5
.#...
.##..
.....
.....
.....
---+/

void main(string[] args) {
  long H, W, K;
  readf(" %d %d %d ", &H, &W, &K);

  auto S = new string[H];
  foreach (ref s; S) s = readln.chomp;

  long[][] ans;
  ans.length = H;
  foreach (ref x; ans) x.length = W;

  long index = 0;
  long sty;
  foreach (y; 0..H) {
    long stx;
    foreach (x; 0..W) {
      if (S[y][x] == '#') {
        ans[y][stx..x+1] = ++index;
        stx = x+1;
      }
    }
    if (stx != 0) {
      ans[y][stx..$] = index;
      foreach (y2; sty..y) {
        ans[y2][] = ans[y][];
      }
      sty = y+1;
    }
  }

  if (sty < H) {
    foreach (y; sty..H) {
      ans[y][] = ans[sty-1][];
    }
  }

  foreach (i, row; ans) {
    foreach (j, cell; row) {
      if (j != 0) " ".write;
      cell.write;
    }
    writeln;
  }
}
