package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

// -----------------------------------------------------------------------------

// IO functions

var (
	nextToken    func() ([]byte, error)
	OutputBuffer *bufio.Writer
	OutputWriter io.Writer
)

func init() {
	SetInput(os.Stdin)
	SetOutput(os.Stdout)
}

func SetInteractive(w io.Writer, r io.Reader) {
	OutputBuffer = nil
	OutputWriter = w
}

func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial
}

func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}
func reads() string {
	return string(readb())
}

func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readi() int {
	return int(readll())
}

func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func prf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

func prn(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

func eprf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func eprn(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

func main() {
	defer Flush()

	H := readi()
	W := readi()
	_ = readi()

	s := make([][]byte, H)
	f := make([][]int, H)
	k := 1
	for i := range s {
		s[i] = readb()
		f[i] = make([]int, W)
		for j := range s[i] {
			if s[i][j] == '#' {
				f[i][j] = k
				k++
			}
		}
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if 0 < j {
				if 0 < f[i][j-1] && f[i][j] == 0 {
					f[i][j] = f[i][j-1]
				}
			}
		}
		for j := W - 1; 0 <= j; j-- {
			if j < W-1 {
				if 0 < f[i][j+1] && f[i][j] == 0 {
					f[i][j] = f[i][j+1]
				}
			}
		}
		if 0 < i && f[i][0] == 0 {
			for j := 0; j < W; j++ {
				f[i][j] = f[i-1][j]
			}
		}
	}
	for i := H - 2; 0 <= i; i-- {
		if f[i][0] != 0 {
			continue
		}
		for j := 0; j < W; j++ {
			f[i][j] = f[i+1][j]
		}
	}

	for i := range f {
		sp := ""
		for j := range f[i] {
			prf("%s%d", sp, f[i][j])
			sp = " "
		}
		prn()
	}
}

func dump(f [][]int) {
	for i := range f {
		sp := ""
		for j := range f[i] {
			eprf("%s%03d", sp, f[i][j])
			sp = " "
		}
		eprn()
	}
	eprn()
}


Measured memory_bytes: 4352