#include "bits/stdc++.h"
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream & operator>>(istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

	int H, W, K;
	cin >> H >> W >> K;
	vector<int> cnt(H, 0);
	vector<string> s(H);
	rep(i, H) {
		cin >> s[i];
		rep(j, s[i].size()) {
			if (s[i][j] == '#') cnt[i]++;
		}
	}

	int r[300][300] = { 0 };


	int n = 1;
	rep(h, H) {
		rep(w, W) {
			if (s[h][w] == '#') r[h][w] = n++;
		}
	}
	rep(h, H) {
		rep(w, W) {
			if (w>0 && r[h][w] == 0) r[h][w] = r[h][w-1];
		}
		for (int w = W - 1; w >= 0; w--) {
			if (w+1<W && r[h][w] == 0) r[h][w] = r[h][w + 1];
		}
	}
	rep(h, H) {
		if (h > 0 && r[h][0] == 0) {
			// 上からコピー
			rep(w, W) r[h][w] = r[h - 1][w];
		}
	}
	for (int h = H - 1; h >= 0; h--) {
		if (h + 1 < H && r[h][0] == 0) {
			// 下からコピー
			rep(w, W) r[h][w] = r[h + 1][w];
		}
	}

/*	int n = 1;
	rep(h, H) {
		if (cnt[h] == 0) continue;
		if (cnt[h] == 1) {
			rep(w, W) {
				r[h][w] = n;
			}
			n++;
		}
		else {
			int c = 0;
			rep(w, W) {
				r[h][w] = n;
				if (s[h][w] == '#') {
					c++;
				}
				if (s[h][w] == '#' && c != cnt[h]) n++;
			}
		}
		n++;
	}

	rep(h, H) {
		if (h>0 && r[h][0] == 0) {
			// 上からコピー
			rep(w, W) r[h][w] = r[h - 1][w];
		}
	}
	for(int h=H-1; h>=0; h--){
		if (h+1<H && r[h][0] == 0) {
			// 下からコピー
			rep(w, W) r[h][w] = r[h + 1][w];
		}
	}
*/
	rep(h, H) {
		rep(w, W) cout << r[h][w] << " ";
		cout << endl;
	}

}

Measured memory_bytes: 1664