#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll MAX = 1e9;

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  V<string> c(h);
  rep(i, h) cin >> c[i];

  V<V<int>> ans(h, V<int>(w, 0));
  int s = 0;
  rep(i, h) {
    if (c[i].find("#") != c[i].npos) {
      s = i;
      break;
    }
  }
  int n = 0;
  for (int i = s; i < h; i++) {
    if (c[i].find("#") == c[i].npos) {
      ans[i] = ans[i - 1];
      continue;
    }
    n++;
    int f = c[i].find("#");
    rep(j, f + 1) ans[i][j] = n;
    for (int j = f + 1; j < w; j++) {
      if (c[i][j] == '#') n++;
      ans[i][j] = n;
    }
  }
  for (int i = h - 1; i >= 0; i--) {
    if (ans[i][0] == 0) ans[i] = ans[i + 1];
  }

  rep(i, h) {
    rep(j, w) printf("%d ", ans[i][j]);
    printf("\n");
  }
}
