import sys

input = sys.stdin.readline

H, W = [int(x) for x in input().split()]

a = []

for _ in range(H):

    a.append(list(input().rstrip()))

import numpy as np

a = np.array(a, np.object)

a = a.T

retsu = []

gyou = []

for i in range(W):

    if "#" not in a[i]:

        retsu.append(i)

a = a.T

for i in range(H):

    if "#" not in a[i]:

        gyou.append(i)

a = np.delete(a, retsu, 1)

a = np.delete(a, gyou, 0)

for j in a:

    j = list(j)

    print(("".join(j)))
import sys

input = sys.stdin.readline



h, w = [int(x) for x in input().split()]

a = []

for _ in range(h):

    b = list(input().rstrip())

    if '#' in b:

        a.append(b)

h = len(a)

c = [1]*w

for i in range(w):

    flag = 1

    for j in range(h):

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

            flag = 0

            break

    if flag:

        c[i] = 0

ans = []

for i in range(h):

    res = []

    for j in range(w):

        if c[j]:

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

    ans.append("".join(res))

for i in ans:

    print(i)



import sys

input = sys.stdin.readline
H, W = [int(x) for x in input().split()]
a = []
for _ in range(H):
    a.append(list(input().rstrip()))
import numpy as np

a = np.array(a, np.object)
a = a.T
retsu = []
gyou = []
for i in range(W):
    if "#" not in a[i]:
        retsu.append(i)
a = a.T
for i in range(H):
    if "#" not in a[i]:
        gyou.append(i)
a = np.delete(a, retsu, 1)
a = np.delete(a, gyou, 0)
for j in a:
    j = list(j)
    print(("".join(j)))

import sys

input = sys.stdin.readline
h, w = [int(x) for x in input().split()]
a = []
for _ in range(h):
    b = list(input().rstrip())
    if "#" in b:
        a.append(b)
h = len(a)
c = [1] * w
for i in range(w):
    flag = 1
    for j in range(h):
        if a[j][i] == "#":
            flag = 0
            break
    if flag:
        c[i] = 0
ans = []
for i in range(h):
    res = []
    for j in range(w):
        if c[j]:
            res.append(a[i][j])
    ans.append("".join(res))
for i in ans:
    print(i)

-H, W = [int(x) for x in input().split()] +h, w = [int(x) for x in input().split()] -for _ in range(H): -    a.append(list(input().rstrip())) -import numpy as np - -a = np.array(a, np.object) -a = a.T -retsu = [] -gyou = [] -for i in range(W): -    if "#" not in a[i]: -        retsu.append(i) -a = a.T -for i in range(H): -    if "#" not in a[i]: -        gyou.append(i) -a = np.delete(a, retsu, 1) -a = np.delete(a, gyou, 0) -for j in a: -    j = list(j) -    print(("".join(j))) +for _ in range(h): +    b = list(input().rstrip()) +    if "#" in b: +        a.append(b) +h = len(a) +c = [1] * w +for i in range(w): +    flag = 1 +    for j in range(h): +        if a[j][i] == "#": +            flag = 0 +            break +    if flag: +        c[i] = 0 +ans = [] +for i in range(h): +    res = [] +    for j in range(w): +        if c[j]: +            res.append(a[i][j]) +    ans.append("".join(res)) +for i in ans: +    print(i)