using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static int h, w;
        static string[,] map;
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            h = s[0];
            w = s[1];
            int k = s[2];
            map = new string[h, w];
            int cnt = 1;
            var pozLs = new List<Poz>();
            for (int i = 0; i < h; i++)
            {
                string r = ReadLine();
                for (int j = 0; j < w; j++)
                {
                    if (r[j] == '#')
                    {
                        map[i, j] = cnt.ToString();
                        pozLs.Add(new Poz(i,j));
                        cnt++;
                    }
                    else
                    {
                        map[i, j] = r[j].ToString();
                    }
                }
            }
            
            foreach (var item in pozLs)
            {
                SideDfs(int.Parse(map[item.Xpoz,item.Ypoz]), item.Xpoz,item.Ypoz);
            }
            var ls = new List<Poz2>();
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (map[i,j] != ".")
                    {
                        int n = int.Parse(map[i, j]);
                        ls.Add(new Poz2(n, i, j));
                    }
                }
            }
            foreach (var item in ls)
            {
                VerticalDfs(item.num, item.Xpoz, item.Ypoz);
            }
            /*
            //ラスト
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (map[i, j] != ".") continue;
                    var ls = new List<string>();
                    //4方向
                    for (int dx = -1; dx <= 1; dx++)
                    {
                        for (int dy = -1; dy <= 1; dy++)
                        {
                            if ((dx != 0 && dy == 0) || (dx == 0 && dy != 0))
                            {
                                try
                                {
                                    if (ls.Contains(map[i + dx, j + dy]))
                                    {
                                        map[i, j] = map[i + dx, j + dy];
                                    }
                                    ls.Add(map[i + dx, j + dy]);
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                    }
                }
            }
            */
            for (int i = 0; i < h; i++)
            {
                Write(map[i, 0]);
                for (int j = 1; j < w; j++)
                {
                    Write(" "+map[i,j]);
                }
                Write('\n');
            }

        }

        static void SideDfs(int v, int x, int y)
        {
            map[x, y] = v.ToString();

            for (int dy = -1; dy <= 1; dy++)
            {
                if (dy == 0) continue;
                int ny = y + dy;
                //はみ出ない
                if (0 <= ny && ny < w)
                {
                    if (map[x, ny] == ".")
                    {
                        SideDfs(v,x, ny);
                    }
                }
            }
        }

        static void VerticalDfs(int v, int x, int y)
        {
            map[x, y] = v.ToString();
            for (int dx = -1; dx <= 1; dx++)
            {
                if (dx == 0) continue;
                int nx = x + dx;
                //はみ出ない
                if (0 <= nx && nx < h)
                {
                    if (map[nx, y] == ".")
                    {
                        VerticalDfs(v, nx, y);
                    }
                }
            }
        }


    }

    public class Poz
    {
        public int Xpoz { get; set; }
        public int Ypoz { get; set; }
        public Poz(int i, int j)
        {
            this.Xpoz = i;
            this.Ypoz = j;
        }

    }
    public class Poz2
    {
        public int num { get; set; }
        public int Xpoz { get; set; }
        public int Ypoz { get; set; }
        public Poz2(int n,int i, int j)
        {
            this.num = n;
            this.Xpoz = i;
            this.Ypoz = j;
        }

    }
}


Measured memory_bytes: 36820