H, W = map(int, input().split())



ans = []

# 横白の除去

for h in range(H):

    line = input()

    if "#" in line:

        ans.append(line)



H = len(ans)

W = len(ans[0])



# 縦白の除去

rem_list = []

for w in range(W):

    ver = [s[w] for s in ans]

    if "#" in ver:

        continue

    rem_list.append(w)



for h in range(H):

    new_ans = []

    for w in range(W):

        if w in rem_list:

            continue

        new_ans.append(ans[h][w])

    ans[h] = new_ans



for i in range(len(ans)):

    for j in range(len(ans[0])):

        print(ans[i][j], end="")

        if j >= len(ans[0])-1:

            print()

H, W = list(map(int, input().split()))



ans = []

# 横白の除去

for h in range(H):

    line = eval(input())

    if "#" in line:

        ans.append(line)





lines = list(zip(*ans))

ans = []

# 縦白の除去

for line in lines:

    if "#" in line:

        ans.append(line)



an = list(zip(*ans))



for line in an:

    print((''.join(line)))
H, W = map(int, input().split())
ans = []
# 横白の除去
for h in range(H):
    line = input()
    if "#" in line:
        ans.append(line)
H = len(ans)
W = len(ans[0])
# 縦白の除去
rem_list = []
for w in range(W):
    ver = [s[w] for s in ans]
    if "#" in ver:
        continue
    rem_list.append(w)
for h in range(H):
    new_ans = []
    for w in range(W):
        if w in rem_list:
            continue
        new_ans.append(ans[h][w])
    ans[h] = new_ans
for i in range(len(ans)):
    for j in range(len(ans[0])):
        print(ans[i][j], end="")
        if j >= len(ans[0]) - 1:
            print()

H, W = list(map(int, input().split()))
ans = []
# 横白の除去
for h in range(H):
    line = eval(input())
    if "#" in line:
        ans.append(line)
lines = list(zip(*ans))
ans = []
# 縦白の除去
for line in lines:
    if "#" in line:
        ans.append(line)
an = list(zip(*ans))
for line in an:
    print(("".join(line)))

-H, W = map(int, input().split()) +H, W = list(map(int, input().split())) -    line = input() +    line = eval(input()) -H = len(ans) -W = len(ans[0]) +lines = list(zip(*ans)) +ans = [] -rem_list = [] -for w in range(W): -    ver = [s[w] for s in ans] -    if "#" in ver: -        continue -    rem_list.append(w) -for h in range(H): -    new_ans = [] -    for w in range(W): -        if w in rem_list: -            continue -        new_ans.append(ans[h][w]) -    ans[h] = new_ans -for i in range(len(ans)): -    for j in range(len(ans[0])): -        print(ans[i][j], end="") -        if j >= len(ans[0]) - 1: -            print() +for line in lines: +    if "#" in line: +        ans.append(line) +an = list(zip(*ans)) +for line in an: +    print(("".join(line)))