#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
typedef vector<int> Vector;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

int main(void) {
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<char>> grid(H, vector<char>(W));
    vector<vector<int>> ans(H, vector<int>(W));
    int ichigo_id = 1;
    for(int i = 0; i < H; i++) {
        string tmp;
        cin >> tmp;

        for(int j = 0; j < W; j++) {
            grid[i][j] = tmp[j];
            if(tmp[j] == '#') {
                ans[i][j] = ichigo_id;
                ichigo_id++;
            }
        }
    }

    ichigo_id = 0;
    //左から
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(ans[i][j] == 0) {
                ans[i][j] = ichigo_id;
            } else {
                ichigo_id = ans[i][j];
            }
        }
        ichigo_id = 0;
    }

    //右から
    ichigo_id = 0;
    for(int y = 0; y < H; y++) {
        for(int x = W - 1; x >= 0; x--) {
            if(ans[y][x] == 0) {
                ans[y][x] = ichigo_id;
            } else {
                ichigo_id = ans[y][x];
            }
        }
        ichigo_id = 0;
    }

    //上から
    ichigo_id = 0;
    for(int x = 0; x < W; x++) {
        for(int y = 0; y < H; y++) {
            if(ans[y][x] == 0) {
                ans[y][x] = ichigo_id;
            } else {
                ichigo_id = ans[y][x];
            }
        }
        ichigo_id = 0;
    }

    //下から
    ichigo_id = 0;
    for(int x = 0; x < W; x++) {
        for(int y = H - 1; y >= 0; y--) {
            if(ans[y][x] == 0) {
                ans[y][x] = ichigo_id;
            } else {
                ichigo_id = ans[y][x];
            }
        }
        ichigo_id = 0;
    }
    rep(i, H) print_vector(ans[i]);

    return 0;
}


Measured memory_bytes: 1280