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

mat = []

for i in range(H):

    a = list(eval(input()))

    if '#' in a:

        mat.append(a)

answ = []

for i in range(W):

    flag = False

    for j in range(len(mat)):

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

            flag = True

    if flag:

        answ.append(i)

for i in range(len(mat)):

    ans = [mat[i][j] for j in answ]

    print((''.join(ans)))

        

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

A = []

for i in range(H):

    a = list(eval(input()))

    if '#' in a:

        A.append(a)

ans = []

for col in zip(*A):

    if '#' in col:

        ans.append(col)

for i in zip(*ans):

    print((''.join(i)))
H, W = list(map(int, input().split()))
mat = []
for i in range(H):
    a = list(eval(input()))
    if "#" in a:
        mat.append(a)
answ = []
for i in range(W):
    flag = False
    for j in range(len(mat)):
        if mat[j][i] == "#":
            flag = True
    if flag:
        answ.append(i)
for i in range(len(mat)):
    ans = [mat[i][j] for j in answ]
    print(("".join(ans)))

H, W = list(map(int, input().split()))
A = []
for i in range(H):
    a = list(eval(input()))
    if "#" in a:
        A.append(a)
ans = []
for col in zip(*A):
    if "#" in col:
        ans.append(col)
for i in zip(*ans):
    print(("".join(i)))

-mat = [] +A = [] -        mat.append(a) -answ = [] -for i in range(W): -    flag = False -    for j in range(len(mat)): -        if mat[j][i] == "#": -            flag = True -    if flag: -        answ.append(i) -for i in range(len(mat)): -    ans = [mat[i][j] for j in answ] -    print(("".join(ans))) +        A.append(a) +ans = [] +for col in zip(*A): +    if "#" in col: +        ans.append(col) +for i in zip(*ans): +    print(("".join(i)))