from collections import deque import sys input = sys.stdin.readline H, W = map(int, input().split()) G = [list(input().strip()) for _ in range(H)] dir = [(1, 0), (0, 1), (-1, 0), (0, -1)] for i in range(H): for j in range(W): if G[i][j]==".": continue deq = deque() deq.append((i, j)) seen = set() seen.add((i, j)) while deq: ci, cj = deq.popleft() for di, dj in dir: ni = ci+di nj = cj+dj if 0<=ni=4: for ci, cj in seen: G[ci][cj] = "." for i in range(H): print("".join(G[i]))