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

M = []



for i in range(H):

    M.append(list(eval(input())))



Hs = []

for i in range(H):

    flag = 0

    for j in range(W):

        if M[i][j]!=".":

            flag = 1

    if flag==1:

        Hs.append(i)



Ws = []

for j in range(W):

    flag = 0

    for i in range(H):

        if M[i][j]!=".":

            flag = 1

    if flag==1:

        Ws.append(j)



for i in Hs:

    out = []

    for j in Ws:

        out.append(M[i][j])

    print(("".join(out)))

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



a = []

for i in range(H):

    a.append(list(eval(input())))



line = [0]*H

colu = [0]*W

for i in range(H):

    for j in range(W):

        if a[i][j] == '#':

            line[i]=1

            colu[j]=1



ans=[]

for i in range(H):

    dammy=[]

    for j in range(W):

        if line[i]==1 and colu[j]==1 :

            dammy.append(a[i][j])

    if dammy!=[]:

        ans.append(dammy)



for i in range(len(ans)):

    print((''.join(ans[i])))
H, W = list(map(int, input().split()))
M = []
for i in range(H):
    M.append(list(eval(input())))
Hs = []
for i in range(H):
    flag = 0
    for j in range(W):
        if M[i][j] != ".":
            flag = 1
    if flag == 1:
        Hs.append(i)
Ws = []
for j in range(W):
    flag = 0
    for i in range(H):
        if M[i][j] != ".":
            flag = 1
    if flag == 1:
        Ws.append(j)
for i in Hs:
    out = []
    for j in Ws:
        out.append(M[i][j])
    print(("".join(out)))

[H, W] = list(map(int, input().split()))
a = []
for i in range(H):
    a.append(list(eval(input())))
line = [0] * H
colu = [0] * W
for i in range(H):
    for j in range(W):
        if a[i][j] == "#":
            line[i] = 1
            colu[j] = 1
ans = []
for i in range(H):
    dammy = []
    for j in range(W):
        if line[i] == 1 and colu[j] == 1:
            dammy.append(a[i][j])
    if dammy != []:
        ans.append(dammy)
for i in range(len(ans)):
    print(("".join(ans[i])))

-H, W = list(map(int, input().split())) -M = [] +[H, W] = list(map(int, input().split())) +a = [] -    M.append(list(eval(input()))) -Hs = [] +    a.append(list(eval(input()))) +line = [0] * H +colu = [0] * W -    flag = 0 -        if M[i][j] != ".": -            flag = 1 -    if flag == 1: -        Hs.append(i) -Ws = [] -for j in range(W): -    flag = 0 -    for i in range(H): -        if M[i][j] != ".": -            flag = 1 -    if flag == 1: -        Ws.append(j) -for i in Hs: -    out = [] -    for j in Ws: -        out.append(M[i][j]) -    print(("".join(out))) +        if a[i][j] == "#": +            line[i] = 1 +            colu[j] = 1 +ans = [] +for i in range(H): +    dammy = [] +    for j in range(W): +        if line[i] == 1 and colu[j] == 1: +            dammy.append(a[i][j]) +    if dammy != []: +        ans.append(dammy) +for i in range(len(ans)): +    print(("".join(ans[i])))