/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    vector<string> field(h);

    for(int i = 0; i < h; i++) cin >> field[i];

    vector<vector<int>> ans(h, vector<int>(w));

    int ecnt = 0;

    int cnt = 1;

    vector<int> icnt(h);

    for(int i = 0; i < h; i++){
        int tmpcnt = 0;
        for(int j = 0; j < w; j++){
            if(field[i][j] == '#'){
                tmpcnt++;
            }
        }
        icnt[i] = tmpcnt;
        //cout << tmpcnt << endl;;
    }

    for(int i = 0; i < h; i++){
        //bool empty = true;
        if(i == h - 1 && icnt[i] == 0){
            int st = 0;
            for(int t = i; i >= 0; t--){
                if(icnt[t] != 0){
                    st = t;
                    break;
                }
            }

            for(int j = 0; j < w; j++){
                for(int k = st; k < h; k++){
                    ans[k][j] = ans[st][j];
                }
            }

            break;

        }

        if(icnt[i] == 0){
            ecnt++;
            continue;
        }

        //cout << cnt << endl;
        int tmpcnt = 0;
        for(int j = 0; j < w; j++){
            ans[i][j] = cnt;
            for(int k = i - 1; k >= i - ecnt; k--){
                ans[k][j] = cnt;
            }

            if(field[i][j] == '#'){
                tmpcnt++;
                if(tmpcnt == icnt[i]){
                    for(int k = j; k < w; k++){
                        ans[i][k] = cnt;
                        for(int l = i - 1; l >= i - ecnt; l--){
                        ans[l][k] = cnt;
                    }
                    }

                    

                    cnt++;
                    j = w - 1;
                    continue;
                }
                cnt++;
            }

            
        }

        ecnt = 0;
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(j == w - 1){
                cout << ans[i][j];
                continue;
            }
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

}

Measured memory_bytes: 1280