import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  auto s = readln.splitter.map!(to!int);
  immutable h = s.front; s.popFront();
  immutable w = s.front; s.popFront();
  immutable k = s.front; s.popFront();
  auto a = new char[][](h, w);
  auto d = new int[h];
  foreach (j; 0 .. h) {
    auto t = readln;
    foreach (i; 0 .. w) {
      a[j][i] = t[i];
      if (t[i] == '#') {
        ++d[j];
      }
    }
  }
  int o;
  auto b = new int[][](h, w);
  for (int j = 0; j < h; ) {
    int j1 = j;
    while (j < h && d[j] == 0) ++j;
    int j2 = j;
    while (j2 + 1 < h && d[j2+1] == 0) ++j2;
    ++j2;
    //[j1, j2)
    for (int i = 0; i < w; ) {
      int i1 = i;
      while (i < w && a[j][i] == '.') ++i;
      int i2 = i;
      while (i2 + 1 < w && a[j][i2+1] == '.') ++i2;
      ++i2;
      assert (j1 != j2);
      assert (i1 != i2);
      ++o;
      debug stderr.writefln ("[%d, %d) x [%d, %d)", j1, j2, i1, i2);
      foreach (y; j1 .. j2) {
        foreach (x; i1 .. i2) {
          assert (!b[y][x]);
          b[y][x] = o;
        }
      }
      i = i2;
    }
    j = j2;
  }
  assert (o == k);
  foreach (j; 0 .. h) {
    writefln ("%(%s %)", b[j]);
  }
}

