// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <sstream>
#include <unistd.h>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define rep(n) for(int __x = 0; __x < n; __x++)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (x.at(x.size()-1))

using namespace std;

#define EPS 0.0000000001
#define MOD 1000000007

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

#define MAX_H 300
#define HH (300*300)
#define MAX_K (300*300)

Int H, W, K;
vector<bool> B(HH, false);
vector<Int> M(HH, 0);

Int at(Int x, Int y) {
  return y*W+x;
}

void input() {
  char _c;
  cin >> H >> W >> K;
  loop(h,0,H) {
    loop(w,0,W) {
      cin >> _c;
      if (_c == '#') B.at(at(w, h)) = true;
    }
  }
}

Int color = 1;

struct Point {
  Int x, y;

  Point(): x(0), y(0) {}
  Point(Int x, Int y): x(x), y(y) {}
  bool operator < (const Point &v) const {
    return y != v.y ? y < v.y : x < v.x;
  }

  bool operator == (const Point &v) const {
    return x == v.x && y == v.x;
  }
};

#define DEBUG 0

void dfs(Point upleft, Point downright, Int depth) {
#if DEBUG
  loop(h,0,H) {
    rep(depth) cout << "\t";
    loop(w,0,W) {
      if (upleft.y <= h && h <= downright.y && upleft.x <= w && w <= downright.x) {
        if (B.at(at(w, h))) cout << "o ";
        else cout << "x ";
      } else {
        cout << ". ";
      }
    }
     cout << endl;
  }
  cout << "-----" << endl;
#endif
  if (M.at(at(upleft.x, upleft.y))) return; // done
  vector<Point> ks;
  loop(h,upleft.y,downright.y+1) {
    loop(w,upleft.x,downright.x+1) {
      if (B.at(at(w, h))) {
        ks.push_back(Point(w, h));
      }
      if (ks.size() == 2) goto l1;
    }
  }

l1:
  if (ks.size() == 2) {
    sort(span_all(ks));
    bool horizontal = ks.at(0).y < ks.at(1).y;
    if (horizontal) {
      ks.at(1).x = upleft.x;
      dfs(ks.at(1), downright, depth+1);
      ks.at(1).y--;
      ks.at(1).x = downright.x;
      dfs(upleft, ks.at(1), depth+1);
    } else {
      ks.at(1).y = upleft.y;
      dfs(ks.at(1), downright, depth+1);
      ks.at(1).x--;
      ks.at(1).y = downright.y;
      dfs(upleft, ks.at(1), depth+1);
    }
    return;
  }

  // k = 1
  loop(h,upleft.y,downright.y+1) {
    loop(w,upleft.x,downright.x+1) {
      M.at(at(w, h)) = color;
    }
  }
  color++;
}

void solve() {
  dfs(Point(0, 0), Point(W-1, H-1), 0);
  loop(h,0,H) {
    loop(w,0,W) {
      cout << M.at(at(w, h)) << " ";
    }
    cout << endl;
  }
}

int main(void) {
  input();
  solve();
  return 0;
}



Measured memory_bytes: 1536