Buggy python submission (verdict: Runtime Error):
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    X, Y = LI()
    ans = 0
    if X == 1:
        ans += 300000
    elif X == 2:
        ans += 200000
    elif X == 3:
        ans += 100000

    if Y == 1:
        ans += 300000
    elif Y == 2:
        ans += 200000
    elif Y == 3:
        ans += 100000

    if X == 1 and Y == 1:
        ans += 400000

    print(ans)
    return


# B
def B():
    N = I()
    A = LI()
    A_sum = sum(A)
    cnt = 0
    ans = sum(A)
    for i in range(N):
        cnt += A[i]
        sa = abs(A_sum - cnt - cnt)
        ans = min(ans, sa)
    print(ans)
    return


# C
def C():
    H, W, K = LI()
    s = [S() for i in range(H)]
    ans = [[0] * W for i in range(H)]
    cnt = 1
    index = 0
    for i in range(H):
        if '#' in s[i]:
            index = i
            break

    for i in range(i, H):
        ichigo = 0
        for j in range(W):
            if s[i][j] == '#' and ichigo == 0:
                ichigo += 1
                ans[i][j] = cnt
            elif s[i][j] == '#' and ichigo != 0:
                cnt += 1
                ans[i][j] = cnt
            else:
                ans[i][j] = cnt
        if ichigo == 0:
            ans[i] = ans[i - 1].copy()
        else:
            cnt+=1

    for i in range(0, index):
        ans[i] = ans[index].copy()

    for i in range(H):
        print(''.join([str(j) for j in ans[i]]))
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    C()
    return


# Solve
if __name__ == "__main__":
    C()


Fixed submission:
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    X, Y = LI()
    ans = 0
    if X == 1:
        ans += 300000
    elif X == 2:
        ans += 200000
    elif X == 3:
        ans += 100000

    if Y == 1:
        ans += 300000
    elif Y == 2:
        ans += 200000
    elif Y == 3:
        ans += 100000

    if X == 1 and Y == 1:
        ans += 400000

    print(ans)
    return


# B
def B():
    N = I()
    A = LI()
    A_sum = sum(A)
    cnt = 0
    ans = sum(A)
    for i in range(N):
        cnt += A[i]
        sa = abs(A_sum - cnt - cnt)
        ans = min(ans, sa)
    print(ans)
    return


# C
def C():
    H, W, K = LI()
    s = [S() for i in range(H)]
    ans = [[0] * W for i in range(H)]
    cnt = 1
    index = 0
    for i in range(H):
        if '#' in s[i]:
            index = i
            break

    for i in range(i, H):
        ichigo = 0
        for j in range(W):
            if s[i][j] == '#' and ichigo == 0:
                ichigo += 1
                ans[i][j] = cnt
            elif s[i][j] == '#' and ichigo != 0:
                cnt += 1
                ans[i][j] = cnt
            else:
                ans[i][j] = cnt
        if ichigo == 0:
            ans[i] = ans[i - 1]
        else:
            cnt+=1

    for i in range(0, index):
        ans[i] = ans[index]

    for i in range(H):
        print(' '.join([str(j) for j in ans[i]]))
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    C()
    return


# Solve
if __name__ == "__main__":
    C()