from collections import deque h,w=map(int,input().split()) grid=[list(input()) for _ in range(h)] move=[(1,0),(0,1),(0,-1),(-1,0)] for i in range(h): for j in range(w): change=[] que=deque() if grid[i][j]!=".": word=grid[i][j] que.append((i,j)) change.append((i,j)) grid[i][j]="." while que: nowx,nowy=que.popleft() for x,y in move: if 0<=nowx+x