#include <iostream>
#include <vector>
using namespace std;
#define T vector<vector<char>>
#define I vector<vector<int>>
#define rep(i,m,M) for(int i = m;i<M;i++)
#define inv(i,m,M) for(int i = M-1;i>=m;i--)

int H, W, K;

bool isBerry(T Str)
{
	int xlength = Str.size(), ylength = Str[0].size();
	
	rep(i, 0, ylength)
	{
		rep(j, 0, xlength)
		{
			if (Str[j][i] == '#')
				return true;
		}
	}
	return false;
}

bool isOnlyBerry(T Str)
{
	int xlength = Str.size(), ylength = Str[0].size();
	int count = 0;
	//cout << "Strのよこ : " << Str.size() << "  たて : " << Str[0].size() << endl;
	rep(i, 0, ylength)
	{
		rep(j, 0, xlength)
		{
			if (Str[j][i] == '#')
			{
				count++;
	//			cout << count << endl;
			}
		}
	}
//	cout << "いちご : " << count << endl;
	return (count == 1);
}

void tatecut(T Str, int t,T &S1,T &S2)
{
	int xlength = Str.size(), ylength = Str[0].size();
	rep(i, 0, ylength)
	{
		rep(j, 0, t)
		{
			S1[j][i] = Str[j][i];
		}
		rep(j, t, xlength)
		{
			S2[j - t][i] = Str[j][i];
		}
	}
}

void yokocut(T Str, int s, T& S1, T& S2)
{
	int xlength = Str.size(), ylength = Str[0].size();
	rep(j, 0, xlength)
	{
		rep(i, 0, s)
		{
			S1[j][i] = Str[j][i];
		}
		rep(i, s, ylength)
		{
			S2[j][i - s] = Str[j][i];
		}
		
	}
}


void res(T Str,I &vec,int &k,int X,int Y)
{
	T s1, s2;
//	cout << "X : " << X << "  Y : " << Y << endl;
	int xlength = Str.size(),ylength = Str[0].size();
//	cout << "xlength : " << xlength << "  ylength : " << ylength << endl;
	int x = 0, y = 0;
	bool flag = false,flag2 = false;

	if(isOnlyBerry(Str))
	{
		rep(i, 0, ylength)
		{
			rep(j, 0, xlength)
			{
				vec[X+j][Y+i] = k;
//				cout << "vec[" << X + j << "][" << Y + i << "] = " << k<<endl;
			}
		}
		k++;
		
		return;
	}

	inv(t, 1, xlength)
	{
		T S1(t, vector<char>(ylength));
		T S2(xlength - t, vector<char>(ylength));
		tatecut(Str, t, S1, S2);
		if (isBerry(S1) and isBerry(S2))
		{
			flag = true;
			s1 = S1;
			s2 = S2;
			x = t-1;
//			cout << "x : " << x << endl;
			break;
		}
	}
	if (flag)
	{
//		cout << "s1のよこ : " << s1.size() << "  たて : " << s1[0].size() << endl;

		res(s1, vec, k, x-s1.size()+1, Y);

//		cout << "s2のよこ : " << s2.size() << "  たて : " << s2[0].size() << endl;

		res(s2, vec, k, x+1, Y);
		flag2 = true;
	}
	if (!flag)
	{
		inv(s, 1, ylength)
		{
			T S1(xlength, vector<char>(s));
			T S2(xlength, vector<char>(ylength - s));
			yokocut(Str, s, S1, S2);
			if (isBerry(S1) and isBerry(S2))
			{
				flag = true;
				s1 = S1;
				s2 = S2;
				y = s-1;
				break;
			}
		}
	}
	if (flag and !flag2)
	{
//		cout << "s1のよこ : " << s1.size() << "  たて : " << s1[0].size() << endl;

		res(s1, vec, k, X, y-s1[0].size()+1);

//		cout << "s2のよこ : " << s2.size() << "  たて : " << s2[0].size() << endl;

		res(s2, vec, k, X, y+1);
	}
}

int main()
{
	
	cin >> H >> W >> K;
	vector<vector<char>>s(W, vector<char>(H));
	vector<vector<int>> ans(W,vector<int>(H));
	I vec(W,vector<int>(H));
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> s[j][i];

		}
	}
//	cout << "よこ : " << s.size() << "  たて : " << s[0].size() << endl;
	int k = 1;
	res(s, vec, k,0,0);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cout << vec[j][i] << " ";

		}
		cout << endl;
	}
}



Measured memory_bytes: 31872