#n130. p2. 製作看板|
r,c = map(int, input().split())
w = [i for i in input()]
maze = [[i for i in input()] for _ in range(r)]
_count = sum([i.count(".") for i in maze])
total = (_count-len(w))//2
for R in range(r):
for C in range(c):
if maze[R][C]==".":
if total ==0:
if len(w)!=0:
a = w.pop(0)
maze[R][C] = a
else:
total-=1
for R in range(r):
for C in range(c):
print(maze[R][C],end ="")
print("")