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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            input_iter = LazyLoadAllLines();
            //------------------------------------------------//
            var h = Read<long>();
            var w = Read<long>();
            var k = Read<long>();
            //var s = Read();
            List<string> sls = new List<string>();
            for(int i = 0; i < h; ++i)
            {
                sls.Add(Read());
            }
            //var als = Read<long>(n);
            //var fls = Read<long>(n);
            //List<long> als = new List<long>(), bls = new List<long>();
            /*List<List<long>> abls = new List<List<long>>();
            List<long> cls = new List<long>();
            for (int i = 0; i < m; ++i)
            {
                abls.Add(Read<long>(2));
                --abls[i][0];
                --abls[i][1];
                cls.Add(Read<long>());
            }
            var q = Read<long>();
            List<List<long>> stls = new List<List<long>>();
            for (int i = 0; i < q; ++i)
            {
                stls.Add(Read<long>(2));
                --stls[i][0];
                --stls[i][1];
            }*/

            //als.Sort((l, r) => (int)(l - r));

            List<int[]> als = new List<int[]>();
            List<int> aTemp = new List<int>();
            int[] aTempSave = new int[] {0};
            var id = 1;
            var toCopyNum = 1;
            for(int i = 0; i < h; ++i)
            {
                if (sls[i].Contains('#'))
                {
                    // l -> r greed
                    var sharpId = -1;
                    for (int j = 0; j < w; ++j)
                    {
                        aTemp.Add(id);
                        if(sls[i][j] == '#')
                        {
                            sharpId = j;
                            ++id;
                        }
                    }
                    for (int j = sharpId + 1; j < w; ++j) --aTemp[j];

                    for (int j = 0; j < toCopyNum; ++j) als.Add(aTemp.ToArray());
                    toCopyNum = 1;
                    aTempSave = aTemp.ToArray();
                    aTemp.Clear();
                }
                else
                {
                    ++toCopyNum;
                }
            }

            if(toCopyNum > 1)
            {
                for (int j = 1; j < toCopyNum; ++j) als.Add(aTempSave);
            }

            for (int i = 0; i < h; ++i)
            {
                Console.WriteLine(string.Join(" ", als[i]));
            }
        }

        static IEnumerator<string> input_iter;

        static _T Read<_T>() where _T : struct
        {
            input_iter.MoveNext();
            return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
        }
        static string Read()
        {
            input_iter.MoveNext();
            return input_iter.Current;
        }
        static List<_T> Read<_T>(long num) where _T : struct { return new List<_T>(Enumerate<_T>(num)); }


        static IEnumerable<_T> Enumerate<_T>(long num)
        {
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                yield return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
            }
        }
        static IEnumerator<string> LazyLoadAllLines()
        {
            string line;
            do
            {
                line = Console.ReadLine();
                foreach (var s in line.Split(' '))
                    yield return s;
            } while (line != null);
        }

        public class PriorityQueue<T> where T : IComparable
        {
            private IComparer<T> comparer = null;
            private bool isAccendingOrder;

            private List<T> heap;
            private int heapCurrentSize = 0;

            //public int Count { get; private set; } = 0;

            public PriorityQueue(IComparer<T> comparer, int initialHeapSize = 256)
            {
                heap = new List<T>(initialHeapSize);
                this.comparer = comparer;
            }

            public PriorityQueue(bool isAccending = true, int initialHeapSize = 256)
            {
                heap = new List<T>(initialHeapSize);
                isAccendingOrder = isAccending;
            }

            private int Compare(T x, T y)
            {
                if (comparer != null) return comparer.Compare(x, y);
                return isAccendingOrder ? x.CompareTo(y) : y.CompareTo(x);
            }

            public bool Empty()
            {
                return Count() == 0;
            }

            public int Count()
            {
                return heapCurrentSize;
            }

            public void Push(T x)
            {
                //node number
                var idx = heapCurrentSize++;
                if (heapCurrentSize > heap.Count) heap.Capacity *= 2;

                while (idx > 0)
                {
                    //parent node number
                    var parentIdx = (idx - 1) / 2;

                    if (Compare(heap[parentIdx], x) <= 0) break;

                    heap[idx] = heap[parentIdx];
                    idx = parentIdx;
                }

                heap[idx] = x;
            }

            public T Pop()
            {
                T ret = heap[0];
                T x = heap[--heapCurrentSize];

                int idx = 0;
                while (idx * 2 + 1 < heapCurrentSize)
                {
                    //children
                    int a = idx * 2 + 1;
                    int b = idx * 2 + 2;

                    if (b < heapCurrentSize && Compare(heap[b], heap[a]) < 0) a = b;

                    if (Compare(heap[a], x) >= 0) break;

                    heap[idx] = heap[a];
                    idx = a;
                }

                heap[idx] = x;

                return ret;
            }

            public T Peek()
            {
                return heap[0];
            }

            public bool Contains(T x)
            {
                for (int i = 0; i < heapCurrentSize; i++) if (x.Equals(heap[i])) return true;
                return false;
            }

            public void Clear()
            {
                while (heapCurrentSize > 0) Pop();
            }

            public IEnumerator<T> GetEnumerator()
            {
                var temp = new List<T>();

                while (heapCurrentSize > 0)
                {
                    temp.Add(Pop());
                }

                foreach (var value in temp)
                {
                    Push(value);
                    yield return value;
                }
            }

            public T[] ToArray()
            {
                T[] array = new T[heapCurrentSize];
                int i = 0;

                foreach (var r in this)
                {
                    array[i] = r;
                    ++i;
                }

                return array;
            }
        }
    }
}


Measured memory_bytes: 18648