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

namespace DDCC2020C2
{
    class Program
    {
        static char[,] s;
        static int[,] ans;
        static int num;
        static void Main(string[] args)
        {
            var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var inputInt = int.Parse(Console.ReadLine());

            int H = inputArr[0];
            int W = inputArr[1];
            int K = inputArr[2];

            s = new char[H, W];

            for (int i = 0; i < H; i++)
            {
                var input = Console.ReadLine();

                for (int j = 0; j < W; j++)
                {
                    s[i, j] = input[j];
                }
            }

            ans = new int[H, W];
            num = 1;

            Devide(s, 0, 0);


            //string ans = "";

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    Console.Write(ans[i, j] + " ");
                }
                Console.WriteLine();
            }

            Console.ReadKey();
        }

        static void Devide(char[,] si, int y, int x)
        {
            int h = si.GetLength(0);
            int w = si.GetLength(1);

            //イチゴの探索
            int h1 = -1;
            int w1 = -1;
            int h2 = -1;
            int w2 = -1;
            int count = 0;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (si[i, j] == '#')
                    {
                        if (count == 0)
                        {
                            h1 = i;
                            w1 = j;
                            count++;
                        }
                        else
                        {
                            h2 = i;
                            w2 = j;
                            count++;
                            break;
                        }
                    }
                }
                if (count > 1) break;
            }

            //イチゴが一個しか含まれていない！
            if (count == 1)
            {
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        ans[y + i, x + j] = num;
                    }
                }
                num++;
                return;
            }

            //二個以上含まれていたら分ける
            if (h1 < h2)
            {
                //h2で切る
                char[,] s1 = new char[h2, w];
                char[,] s2 = new char[h - h2, w];
                for (int i = 0; i < h2; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        s1[i, j] = si[i, j];
                    }
                }
                for (int i = 0; i < h - h2; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        s2[i, j] = si[h2 + i, j];
                    }
                }
                Devide(s1, y, x);
                Devide(s2, y + h2, x);
            }
            else
            {
                //w2で切る
                char[,] s1 = new char[h, w2];
                char[,] s2 = new char[h, w - w2];
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w2; j++)
                    {
                        s1[i, j] = si[i, j];
                    }
                    for (int j = 0; j < w - w2; j++)
                    {
                        s2[i, j] = si[i, w2 + j];
                    }
                }
                Devide(s1, y, x);
                Devide(s2, y, x + w2);
            }

        }
    }
}


Measured memory_bytes: 43324