#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> g(h);
    for (int i = 0; i < h; i++)
    {
        cin >> g[i];
    }
    vector<vector<int>> ans(h, vector<int>(w, 0));
    int now = 1;
    set<int> unpainted;
    for (int i = 0; i < h; i++)
    {
        bool flg = false;
        for (int j = 0; j < w; j++)
        {
            if (g[i][j] == '#')
            {
                flg = true;
            }
        }
        if (!flg)
        {
            unpainted.insert(i);
            continue;
        }
        int r = 0;
        for (int l = 0; l < w; l++)
        {
            while (r < w && g[i][r] == '.')
            {
                r++;
            }
            // cout << l << ' ' << r << endl;
            if (r == w && g[i][w - 1] == '.')
            {
                for (int j = l; j < w; j++)
                {
                    ans[i][j] = now - 1;
                }
                l = r;
                if (l == r)
                    r++;
            }
            else
            {
                for (int j = l; j <= r; j++)
                {
                    ans[i][j] = now;
                }
                l = r;
                if (l == r)
                    r++;
                now++;
            }
        }
    }

    set<int> tmp = unpainted;

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout << ans[i][j]<<' ';
    //     }
    //     cout<<endl;
    // }

    for (auto i : tmp)
    {
        bool flg = false;
        for (int j = 0; j < w; j++)
        {
            if (ans[i][j] != 0)
            {
                flg = true;
            }
        }
        if (flg)
        {
            continue;
        }
        for (int y = i; y < h; y++)
        {
            if (!unpainted.count(y))
            {
                for (int yy = i; yy < y; yy++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        ans[yy][j] = ans[y][j];
                    }
                }
                break;
            }
        }
    }

    if (unpainted.count(h - 1))
    {
        for (int y = h - 1; y >= 0; y--)
        {
            if (!unpainted.count(y))
            {
                // cout << y << endl;
                for (int yy = h - 1; yy > y; yy--)
                {
                    for (int j = 0; j < w; j++)
                    {
                        ans[yy][j] = ans[y][j];
                    }
                }
                break;
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280