//  [go]
package main

import "fmt"
import "bufio"
import "os"
import "strconv"
import "sort"

var _sw = bufio.NewScanner(os.Stdin)

type Pos struct {
	X, Y int
}

type Rect struct {
	L, R, U, B int
}

var H, W, K int

var (
	ToUp     = Pos{0, -1}
	ToLeft   = Pos{-1, 0}
	ToBottom = Pos{0, +1}
	ToRight  = Pos{+1, 0}
)

func main() {
	H = NextInt()
	W = NextInt()
	K = NextInt()

	pos := make([]Pos, 0, K)

	in := make([][]bool, H)
	for y := range in {
		in[y] = make([]bool, W)
		s := NextString()
		for x := range s {
			in[y][x] = s[x] == '#'
			if in[y][x] {
				pos = append(pos, Pos{X: x, Y: y})
			}
		}
	}

	if len(pos) != K {
		panic("K mismatch")
	}

	out := make([][]int, H)
	for y := range out {
		out[y] = make([]int, W)
	}

	for i, p := range pos {
		out[p.Y][p.X] = i + 1
	}

	for i, p := range pos {
		r := Rect{L: p.X, R: p.X, U: p.Y, B: p.Y}
		deltas := []Pos{
			Pos{0, -1},
			Pos{-1, 0},
			Pos{+1, 0},
			Pos{0, +1},
		}
		for _, d := range deltas {
			for {
				var ok bool
				r, ok = extendRect(out, r, i+1, d)
				if !ok {
					break
				}
			}
		}
	}

	for y := range out {
		for x, n := range out[y] {
			fmt.Print(n)
			if x < W-1 {
				fmt.Print(" ")
			}
		}
		fmt.Println()
	}
}

func extendRect(out [][]int, r Rect, i int, d Pos) (Rect, bool) {
	check := func(x_, y_ int) bool {
		if 0 <= x_ && x_ < W && 0 <= y_ && y_ < H {
			//
		} else {
			return false
		}

		if out[y_][x_] != 0 && out[y_][x_] != i {
			return false
		}
		return true
	}

	if d == ToUp {
		y := r.U
		for x := r.L; x <= r.R; x++ {
			if !check(x+d.X, y+d.Y) {
				return r, false
			}
		}
	} else if d == ToBottom {
		y := r.B
		for x := r.L; x <= r.R; x++ {
			if !check(x+d.X, y+d.Y) {
				return r, false
			}
		}
	} else if d == ToLeft {
		x := r.L
		for y := r.U; y <= r.B; y++ {
			if !check(x+d.X, y+d.Y) {
				return r, false
			}
		}
	} else if d == ToRight {
		x := r.R
		for y := r.U; y <= r.B; y++ {
			if !check(x+d.X, y+d.Y) {
				return r, false
			}
		}
	} else {
		panic("unknown d")
	}

	if d == ToUp {
		y := r.U
		for x := r.L; x <= r.R; x++ {
			out[y+d.Y][x+d.X] = i
		}
		r.U -= 1
	} else if d == ToBottom {
		y := r.B
		for x := r.L; x <= r.R; x++ {
			out[y+d.Y][x+d.X] = i
		}
		r.B += 1
	} else if d == ToLeft {
		x := r.L
		for y := r.U; y <= r.B; y++ {
			out[y+d.Y][x+d.X] = i
		}
		r.L -= 1
	} else if d == ToRight {
		x := r.R
		for y := r.U; y <= r.B; y++ {
			out[y+d.Y][x+d.X] = i
		}
		r.R += 1
	} else {
		panic("unknown d")
	}

	return r, true
}

func extend(out [][]int, pp []Pos, i int, d Pos) ([]Pos, bool) {
	for _, p := range pp {
		x, y := p.X, p.Y
		x_, y_ := x+d.X, y+d.Y

		if 0 <= x_ && x_ < W && 0 <= y_ && y_ < H {
			//
		} else {
			return pp, false
		}

		if out[y_][x_] != 0 && out[y_][x_] != i {
			return pp, false
		}
	}

	newPP := append([]Pos{}, pp...)
	for _, p := range pp {
		x, y := p.X, p.Y
		x_, y_ := x+d.X, y+d.Y
		if out[y_][x_] != i {
			out[y_][x_] = i
			newPP = append(newPP, Pos{x_, y_})
		}
	}

	return newPP, true
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextInts(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = NextInt()
	}
	return a
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func Bounded(lower, n, upper int) int {
	return Min(upper, Max(lower, n))
}

func SortInts(xs []int) {
	sort.Sort(sort.IntSlice(xs))
}

func ReverseSortInts(xs []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(xs)))
}