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

a = [list(eval(input())) for _ in range(h)]



l = []

for i, v in enumerate(a):

    if "#" not in v:

        l.append(i)

for i in l[::-1]:

    a.pop(i)



a = list(zip(*a))

l = []

for i, v in enumerate(a):

    if "#" not in v:

        l.append(i)

for i in l[::-1]:

    a.pop(i)



a = list(zip(*a))

for i in a:

    print(("".join(i)))
import numpy as np

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

a = [list(eval(input())) for _ in range(h)]



a = np.array(a).reshape(h, w)

a = [i for i in a if "#" in i]



a = np.array(a).T

a = [i for i in a if "#" in i]



a = np.array(a).T

for i in a:

    print(("".join(i)))

h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
l = []
for i, v in enumerate(a):
    if "#" not in v:
        l.append(i)
for i in l[::-1]:
    a.pop(i)
a = list(zip(*a))
l = []
for i, v in enumerate(a):
    if "#" not in v:
        l.append(i)
for i in l[::-1]:
    a.pop(i)
a = list(zip(*a))
for i in a:
    print(("".join(i)))

import numpy as np

h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
a = np.array(a).reshape(h, w)
a = [i for i in a if "#" in i]
a = np.array(a).T
a = [i for i in a if "#" in i]
a = np.array(a).T
for i in a:
    print(("".join(i)))

+import numpy as np + -l = [] -for i, v in enumerate(a): -    if "#" not in v: -        l.append(i) -for i in l[::-1]: -    a.pop(i) -a = list(zip(*a)) -l = [] -for i, v in enumerate(a): -    if "#" not in v: -        l.append(i) -for i in l[::-1]: -    a.pop(i) -a = list(zip(*a)) +a = np.array(a).reshape(h, w) +a = [i for i in a if "#" in i] +a = np.array(a).T +a = [i for i in a if "#" in i] +a = np.array(a).T