Buggy python submission (verdict: Runtime Error):
import numpy as np
H,W,K=map(int, input().split())
M=np.array([list(input()) for _ in range(H)])
ans=np.zeros((H,W),int)
k=0

for i in range(H):
    l=0
    for j in range(W):
        if M[i,j]=='#':
            k+=1
            ans[i,l:j+1]=k
            l=j+1

# for i in range(H):
#     if sum(ans[i,:])==0:
#         if i!=0:
#             ans[i,:]=ans[i-1,:]
#         if i==0:
#             ans[i,:]=ans[1,:]
            
for i in range(H):
    for j in range(W):
        if ans[i,j]==0:
            ans[i,j]=ans[i,j-1]
            
            
for j in range(W):
    J=W-j-1
    for i in range(H):
        I=H-i-1
        if ans[I,J]==0:
            ans[I,J]=ans[I+1,J]
            
for row in ans:
    print(*row)

Fixed submission:
import numpy as np
H,W,K=map(int, input().split())
M=np.array([list(input()) for _ in range(H)])
ans=np.zeros((H,W),int)
k=0

for i in range(H):
    l=0
    for j in range(W):
        if M[i,j]=='#':
            k+=1
            ans[i,l:j+1]=k
            l=j+1

            
for i in range(H):
    for j in range(W):
        if ans[i,j]==0:
            ans[i,j]=ans[i,j-1]
            
            
for j in range(W):
    J=W-j-1
    for i in range(H):
        I=H-i-1
        if I!=H-1 and ans[I,J]==0:
            ans[I,J]=ans[I+1,J]


for i in range(H):
    if sum(ans[i,:])==0:
        if i!=0:
            ans[i,:]=ans[i-1,:]
        if i==0:
            ans[i,:]=ans[1,:]
            
for row in ans:
    print(*row)

Buggy python submission (verdict: Runtime Error):
import numpy as np
H,W,K=map(int, input().split())
M=np.array([list(input()) for _ in range(H)])
ans=np.zeros((H,W),int)
k=0

for i in range(H):
    l=0
    for j in range(W):
        if M[i,j]=='#':
            k+=1
            ans[i,l:j+1]=k
            l=j+1

# for i in range(H):
#     if sum(ans[i,:])==0:
#         if i!=0:
#             ans[i,:]=ans[i-1,:]
#         if i==0:
#             ans[i,:]=ans[1,:]
            
for i in range(H):
    for j in range(W):
        if ans[i,j]==0:
            ans[i,j]=ans[i,j-1]
            
            
for j in range(W):
    J=W-j-1
    for i in range(H):
        I=H-i-1
        if ans[J,I]==0:
            ans[J,I]=ans[J+1,I]
            
for row in ans:
    print(*row)

Fixed submission:
import numpy as np
H,W,K=map(int, input().split())
M=np.array([list(input()) for _ in range(H)])
ans=np.zeros((H,W),int)
k=0

for i in range(H):
    l=0
    for j in range(W):
        if M[i,j]=='#':
            k+=1
            ans[i,l:j+1]=k
            l=j+1

            
for i in range(H):
    for j in range(W):
        if ans[i,j]==0:
            ans[i,j]=ans[i,j-1]
            
            
for j in range(W):
    J=W-j-1
    for i in range(H):
        I=H-i-1
        if I!=H-1 and ans[I,J]==0:
            ans[I,J]=ans[I+1,J]


for i in range(H):
    if sum(ans[i,:])==0:
        if i!=0:
            ans[i,:]=ans[i-1,:]
        if i==0:
            ans[i,:]=ans[1,:]
            
for row in ans:
    print(*row)

Buggy python submission (verdict: Runtime Error):
import numpy as np
H,W,K=map(int, input().split())
M=np.array([list(input()) for _ in range(H)])
ans=np.zeros((H,W),int)
k=0
l
for i in range(H):
    l=0
    for j in range(W):
        if M[i,j]=='#':
            k+=1
            ans[i,l:j+1]=k
            l=j+1

for i in range(H):
    if sum(ans[i,:])==0:
        if i!=0:
            ans[i,:]=ans[i-1,:]
        if i==0:
            ans[i,:]=ans[1,:]
for i in range(H):
    for j in range(W):
        if ans[i,j]==0:
            ans[i,j]=ans[i,j-1]
            
for row in ans:
    print(*row)

Fixed submission:
import numpy as np
H,W,K=map(int, input().split())
M=np.array([list(input()) for _ in range(H)])
ans=np.zeros((H,W),int)
k=0

for i in range(H):
    l=0
    for j in range(W):
        if M[i,j]=='#':
            k+=1
            ans[i,l:j+1]=k
            l=j+1

            
for i in range(H):
    for j in range(W):
        if ans[i,j]==0:
            ans[i,j]=ans[i,j-1]
            
            
for j in range(W):
    J=W-j-1
    for i in range(H):
        I=H-i-1
        if I!=H-1 and ans[I,J]==0:
            ans[I,J]=ans[I+1,J]


for i in range(H):
    if sum(ans[i,:])==0:
        if i!=0:
            ans[i,:]=ans[i-1,:]
        if i==0:
            ans[i,:]=ans[1,:]
            
for row in ans:
    print(*row)