using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace AtCoderDISCO
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] info = Console
                .ReadLine()
                .Split()
                .Select(x => Convert.ToInt32(x))
                .ToArray();
            int H = info[0];
            int W = info[1];
            int K = info[2];
            string[] rows = Enumerable
                .Range(0, H)
                .Select(x => Console.ReadLine())
                .ToArray();

            //int[,] matrix_cnt = new int[H + 1, W + 1];
            //for (int i = 1; i <= H; ++i)
            //    for (int j = 1; j <= W; ++j)
            //        matrix_cnt[i, j] = matrix_cnt[i - 1, j] + matrix_cnt[i, j - 1] - matrix_cnt[i - 1, j - 1] + (rows[i - 1][j - 1] == '#' ? 1 : 0);
            int[,] output_matrix = IterativeSol(H, W, K, rows);
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < H; ++i, builder.Append(Environment.NewLine))
                for (int j = 0; j < W; ++j)
                    builder.Append(output_matrix[i, j].ToString() + " ");
            Console.WriteLine(builder);
        }

        //static void Paint(int r_f, int r_to, int c_f, int c_to, string[] matrix, int[,] matrix_cnt, int[,] output_matrix, ref int cnt)
        //{
        //    int s = matrix_cnt[r_to + 1, c_to + 1] - matrix_cnt[r_to + 1, c_f] - matrix_cnt[r_f, c_to + 1] + matrix_cnt[r_f, c_f];
        //    if (s == 1)
        //    {
        //        for (int i = r_f; i <= r_to; ++i)
        //            for (int j = c_f; j <= c_to; ++j)
        //                output_matrix[i, j] = cnt;
        //        ++cnt;
        //        return;
        //    }

        //    bool rs1 = Paint(r_f, i, c_f, j, matrix, matrix_cnt, output_matrix, ref cnt);
        //    bool rs2 = Paint(i + 1, r_to, j + 1, c_to, matrix, matrix_cnt, output_matrix, ref cnt);

        //}


        static int[,] IterativeSol(int H, int W, int K, string[] rows)
        {
            int[,] output_matrix = new int[H, W];
            int cnt = 1;
            int[] s_r = new int[H];
            for (int i = 0; i < H; ++i)
                for (int j = 0; j < W; ++j)
                    if (rows[i][j] == '#')
                        ++s_r[i];


            List<int> s_rl = new List<int>();
            for (int i = 0; i < H; ++i)
                if (s_r[i] > 0)
                    s_rl.Add(i);

            for(int i = 0; i < s_rl.Count; ++i)
            {
                int r_b = 0;
                int r_e = H - 1;

                if (i > 0) r_b = s_rl[i - 1] + 1;
                if (i + 1 < s_rl.Count) r_e = s_rl[i];

                List<int> col = new List<int>();
                for (int r = r_b; r <= r_e; ++r)
                    for (int c = 0; c < W; ++c)
                        if (rows[r][c] == '#')
                            col.Add(c);

                col.Sort();
                for(int c = 0; c < col.Count; ++c, ++cnt)
                {
                    int c_b = 0;
                    int c_e = W - 1;

                    if (c > 0) c_b = col[c - 1] + 1;
                    if (c + 1 < col.Count) c_e = col[c];

                    for (int rr = r_b; rr <= r_e; ++rr)
                        for (int cc = c_b; cc <= c_e; ++cc)
                            output_matrix[rr, cc] = cnt;
                }
            }

            return output_matrix;
        }
    }
}


Measured memory_bytes: 20956