import numpy as np



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



li = []

for i in range(h):

    a = list(input())

    li.append(a)



count = 0

li_2 = []

for i in range(h):

    for j in range(w):

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

            li_2.append(list(li[i][:]))

            count += 1

            break

li_3 = []

li_2 = [list(x) for x in zip(*li_2)]



count2= 0

for j in range(w):

    for k in range(count):

        if li_2[j][k] == '#':

            li_3.append(li_2[j][:])

            count2 += 1

            break





li_3 = [list(y) for y in zip(*li_3)]



for i in range(count):

    for j in range(count2):

        print(li_3[i][j], end='')

        if j == count2-1:

            print('')



import itertools



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



area = []

for i in range(h):

    array = list(input())

    area.append(array)



a = list(itertools.chain.from_iterable(area))



yoko = []

tate = []



for i in range(h):

    cnt = 0

    for j in range(w):

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

            cnt += 1

    if cnt == 0:

        yoko.append(i)



for i in range(w):

    b = a[i::w]

    if len(set(b)) == 1 and '.' in set(b):

        tate.append(i)



for i in range(h):

    flg = False

    for j in range(w):

        if j in set(tate):

            continue

        elif i in set(yoko):

            flg = True

            continue

        else:

            print(area[i][j], end='')

    if flg == False:

        print()

import numpy as np

h, w = map(int, input().split())
li = []
for i in range(h):
    a = list(input())
    li.append(a)
count = 0
li_2 = []
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":
            li_2.append(list(li[i][:]))
            count += 1
            break
li_3 = []
li_2 = [list(x) for x in zip(*li_2)]
count2 = 0
for j in range(w):
    for k in range(count):
        if li_2[j][k] == "#":
            li_3.append(li_2[j][:])
            count2 += 1
            break
li_3 = [list(y) for y in zip(*li_3)]
for i in range(count):
    for j in range(count2):
        print(li_3[i][j], end="")
        if j == count2 - 1:
            print("")

import itertools

h, w = map(int, input().split())
area = []
for i in range(h):
    array = list(input())
    area.append(array)
a = list(itertools.chain.from_iterable(area))
yoko = []
tate = []
for i in range(h):
    cnt = 0
    for j in range(w):
        if area[i][j] == "#":
            cnt += 1
    if cnt == 0:
        yoko.append(i)
for i in range(w):
    b = a[i::w]
    if len(set(b)) == 1 and "." in set(b):
        tate.append(i)
for i in range(h):
    flg = False
    for j in range(w):
        if j in set(tate):
            continue
        elif i in set(yoko):
            flg = True
            continue
        else:
            print(area[i][j], end="")
    if flg == False:
        print()

-import numpy as np +import itertools -li = [] +area = [] -    a = list(input()) -    li.append(a) -count = 0 -li_2 = [] +    array = list(input()) +    area.append(array) +a = list(itertools.chain.from_iterable(area)) +yoko = [] +tate = [] +    cnt = 0 -        if li[i][j] == "#": -            li_2.append(list(li[i][:])) -            count += 1 -            break -li_3 = [] -li_2 = [list(x) for x in zip(*li_2)] -count2 = 0 -for j in range(w): -    for k in range(count): -        if li_2[j][k] == "#": -            li_3.append(li_2[j][:]) -            count2 += 1 -            break -li_3 = [list(y) for y in zip(*li_3)] -for i in range(count): -    for j in range(count2): -        print(li_3[i][j], end="") -        if j == count2 - 1: -            print("") +        if area[i][j] == "#": +            cnt += 1 +    if cnt == 0: +        yoko.append(i) +for i in range(w): +    b = a[i::w] +    if len(set(b)) == 1 and "." in set(b): +        tate.append(i) +for i in range(h): +    flg = False +    for j in range(w): +        if j in set(tate): +            continue +        elif i in set(yoko): +            flg = True +            continue +        else: +            print(area[i][j], end="") +    if flg == False: +        print()