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

namespace A_1116_B
{
    class Program
    {
        class A_2019_1123_C
        {
            class map
            {
                public bool[][] isStrbarry;
                public int[][] num;

                public map(int H, int W)
                {
                    isStrbarry = new bool[H][];
                    num = new int[H][];
                    for (int i=0;i<H;i++)
                    {
                        isStrbarry[i] = new bool[W];
                        num[i] = new int[W];
                        for(int j=0;j<W;j++)
                        {
                            num[i][j] = 0;
                        }
                    }
                }
            }

            public void run()
            {
                //入力部
                string[] str = Console.ReadLine().Split(' ');
                int H = int.Parse(str[0]);
                int W = int.Parse(str[1]);
                int K = int.Parse(str[2]);
                map map = new map(H,W);
                for(int i=0;i<H;i++)
                {
                    string strCake = Console.ReadLine();
                    for(int j=0;j<W;j++)
                    {
                        map.isStrbarry[i][j] = (strCake[j] == '#');
                    }
                }

                

                //処理
                int strberryNum = 0;

                for(int i=0;i<H;i++)
                {

                    bool isFirstInLine = true;
                    for(int j=0;j<W;j++)
                    {
                        if(map.isStrbarry[i][j])
                        {
                            strberryNum++;
                            if(isFirstInLine)
                            {
                                for(int k=0;k<j;k++)
                                    map.num[i][k] = strberryNum;
                                isFirstInLine = false;
                            }
                            map.num[i][j] = strberryNum;

                        }
                        else if(!isFirstInLine)
                        {
                            map.num[i][j] = strberryNum;
                        }
                    }

                    if (isFirstInLine)
                    {
                        if (i != 0)
                        {
                            map.num[i] = map.num[i - 1];
                        }
                    }


                }
                int l = 0;

                for(l=0;l<H;l++)
                {
                    if (map.num[l][0] != 0)
                        break;
                }
                for(int i=0;i<l;i++)
                {
                    map.num[i] = map.num[l];
                }

                //出力
                for(int i=0;i<H;i++)
                {
                    string spl = "";
                    for (int j=0;j<W;j++)
                    {
                        spl += map.num[i][j].ToString();
                        if (j < W - 1) spl += " ";

                        //Console.Write(map.num[i][j].ToString());
                        //if(j<W-1) Console.Write(" ");
                    }

                    //Console.WriteLine();
                    Console.WriteLine(spl);
                }





            }
        }



        static void Main(string[] args)
        {
            A_2019_1123_C mainClass = new A_2019_1123_C();
            mainClass.run();


            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 18456