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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int h,w,k;cin>>h>>w>>k;
	vector<vector<char>> s(h,vector<char>(w));
	int i,j;
	rep(i,h)rep(j,w)cin>>s[i][j];
	vector<bool> found(h,false);
	rep(i,h)rep(j,w)if(s[i][j]=='#')found[i]=true;
	vector<vector<int>> ans(h,vector<int>(w,-1));
	int now=0;
	rep(i,h)
	{
		if(!found[i])continue;
		int fcome=-1;
		rep(j,w)
		{
			if(s[i][j]=='#')
			{
				if(fcome==-1)fcome=j;
				now++;
			}
			ans[i][j]=now;
		}
		rep(j,fcome)ans[i][j]=ans[i][fcome];
	}
	int first=0;
	rep(i,h)
	{
		if(found[i])
		{
			first=i;
			break;
		}
	}
	for(i=first-1;i>=0;i--)
	{
		rep(j,w)ans[i][j]=ans[i+1][j];
	}
	for(i=first+1;i<h;i++)
	{
		if(found[i])continue;
		rep(j,w)ans[i][j]=ans[i-1][j];
	}
	rep(i,h)
	{
		rep(j,w)
		{
			if(j==0)cout<<ans[i][j];
			else cout<<' '<<ans[i][j];
		}
		cout<<endl;
	}
}
