#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
#    h,w,a,b = map(int, input().split())
    h,w,k=map(int,input().split())
    s=[]

    a = [[0] * w for i in range(h)]
    for i in range(h):
        s.append(list(input()))
    temp=1
    new=0
    p=[]
#    print(a)
    for i in range(h):
        for j in range(w):
            if s[i][j]==".":
                a[i][j]=temp
            elif s[i][j]=="#" and new!=0:
                temp+=1
                a[i][j]=temp
            else:
                a[i][j]=temp
                new=1
        if new==1:
            temp+=1
        else:
            p.append(i)
        new=0

#    print(p)
    for i in p:
        for j in range(w):
            if i !=0 and i!= h-1:
                pp=i
                while 1>0:
                    pp+=1
                    if pp in p:
                        continue
                    elif pp==h-1:
                        while 1>0:
                            pp-=1
                            if pp in p:
                                continue
                            else:
                                break
                    else:
                        break
                    break
                a[i][j]=a[pp][j]
            if i==0:
                a[i][j]=a[i+1][j]
            if i==h-1:
                a[i][j]=a[i-1][j]
    if 0 in p:
        for i in range(w):
            a[0][i]=a[1][i]

#    print(s)
    for i in range(h):
        print(*a[i])


if __name__ == "__main__":
    main()

### FIXED CODE ###

#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
#    h,w,a,b = map(int, input().split())
    h,w,k=map(int,input().split())
    s=[]

    a = [[0] * w for i in range(h)]
    for i in range(h):
        s.append(list(input()))
    temp=1
    new=0
    p=[]
#    print(a)
    for i in range(h):
        for j in range(w):
            if s[i][j]==".":
                a[i][j]=temp
            elif s[i][j]=="#" and new!=0:
                temp+=1
                a[i][j]=temp
            else:
                a[i][j]=temp
                new=1
        if new==1:
            temp+=1
        else:
            p.append(i)
        new=0

#    print(p)
    if p:
        for i in p:
            for j in range(w):
                if i !=0 and i!= h-1:
                    pp=i
                    while 1>0:
                        pp+=1
                        if pp in p:
                            continue
                        elif pp==h:
                            while 1>0:
                                pp-=1
                                if pp in p:
                                    continue
                                else:
                                    break
                        else:
                            break
                        break
                    a[i][j]=a[pp][j]
                elif i==h-1:
                    a[i][j]=a[i-1][j]
                else:
                    break
    if 0 in p and h>=2:
        for i in range(w):
            a[0][i]=a[1][i]

#    print(s)
    for i in range(h):
        print(*a[i])


if __name__ == "__main__":
    main()