h, w = list(map(int, input().split()))



A = []

for i in range(h):

    s = list(eval(input()))

    if '#' in s:

        A.append(s)

        

B = [[0] * w for i in range(len(A))]

for i in range(len(A)):

    for j in range(w):

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

            B[i][j] += 1

            

C = [0] * w

for i in range(len(A)):

    for j in range(w):

        C[j] += B[i][j]

        

D = [[] for i in range(len(A))]

for i in range(len(A)):

    for j in range(w):

        if C[j] != 0:

            D[i].append(A[i][j])

            

for i in range(len(A)):

    print((''.join(D[i])))        
h, w = list(map(int, input().split()))



A = []

for i in range(h):

    s = list(eval(input()))

    if '#' in s:

        A.append(s)



h2 = len(A)

for j in range(w - 1, -1, -1):

    for i in range(h2):

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

            break

        elif i == h2 - 1:

            for k in range(h2):

                del A[k][j]

            

for a in A:

    print((''.join(a)))
h, w = list(map(int, input().split()))
A = []
for i in range(h):
    s = list(eval(input()))
    if "#" in s:
        A.append(s)
B = [[0] * w for i in range(len(A))]
for i in range(len(A)):
    for j in range(w):
        if A[i][j] == "#":
            B[i][j] += 1
C = [0] * w
for i in range(len(A)):
    for j in range(w):
        C[j] += B[i][j]
D = [[] for i in range(len(A))]
for i in range(len(A)):
    for j in range(w):
        if C[j] != 0:
            D[i].append(A[i][j])
for i in range(len(A)):
    print(("".join(D[i])))

h, w = list(map(int, input().split()))
A = []
for i in range(h):
    s = list(eval(input()))
    if "#" in s:
        A.append(s)
h2 = len(A)
for j in range(w - 1, -1, -1):
    for i in range(h2):
        if A[i][j] == "#":
            break
        elif i == h2 - 1:
            for k in range(h2):
                del A[k][j]
for a in A:
    print(("".join(a)))

-B = [[0] * w for i in range(len(A))] -for i in range(len(A)): -    for j in range(w): +h2 = len(A) +for j in range(w - 1, -1, -1): +    for i in range(h2): -            B[i][j] += 1 -C = [0] * w -for i in range(len(A)): -    for j in range(w): -        C[j] += B[i][j] -D = [[] for i in range(len(A))] -for i in range(len(A)): -    for j in range(w): -        if C[j] != 0: -            D[i].append(A[i][j]) -for i in range(len(A)): -    print(("".join(D[i]))) +            break +        elif i == h2 - 1: +            for k in range(h2): +                del A[k][j] +for a in A: +    print(("".join(a)))