import numpy

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

grid = numpy.empty([h,w], str)

white_h = []

white_w = []

for i in range(h):

    grid[i] = list(eval(input()))

for i in range(h):

    if "#" not in grid[i]:

        white_h.append(i)

for i in range(w):

    if "#" not in grid[:, i]:

        white_w.append(i)

ans_grid = numpy.empty([h-len(white_h), w-len(white_w)], str)

cnt_h = 0

for i in range(h):

    if i not in white_h:

        cnt_w = 0

        for j in range(w):

            if j not in white_w:

                ans_grid[cnt_h, cnt_w] = grid[i,j]

                cnt_w += 1

        cnt_h += 1

for i in range(len(ans_grid)):

    print(("".join(ans_grid[i])))







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

grid = []

for i in range(h):

    grid.append(list(eval(input())))

h_b = []

w_b = []

for i in range(h):

    if "#" in grid[i]:

        h_b.append(i)

grid_t = [list(x) for x in zip(*grid)]

for i in range(w):

    if "#" in grid_t[i]:

        w_b.append(i)

ans = []

for i in h_b:

    crt = []

    for j in w_b:

        crt.append(grid[i][j])

    ans.append(crt)

for i in range(len(ans)):

    print(("".join(ans[i])))



import numpy

h, w = list(map(int, input().split()))
grid = numpy.empty([h, w], str)
white_h = []
white_w = []
for i in range(h):
    grid[i] = list(eval(input()))
for i in range(h):
    if "#" not in grid[i]:
        white_h.append(i)
for i in range(w):
    if "#" not in grid[:, i]:
        white_w.append(i)
ans_grid = numpy.empty([h - len(white_h), w - len(white_w)], str)
cnt_h = 0
for i in range(h):
    if i not in white_h:
        cnt_w = 0
        for j in range(w):
            if j not in white_w:
                ans_grid[cnt_h, cnt_w] = grid[i, j]
                cnt_w += 1
        cnt_h += 1
for i in range(len(ans_grid)):
    print(("".join(ans_grid[i])))

h, w = list(map(int, input().split()))
grid = []
for i in range(h):
    grid.append(list(eval(input())))
h_b = []
w_b = []
for i in range(h):
    if "#" in grid[i]:
        h_b.append(i)
grid_t = [list(x) for x in zip(*grid)]
for i in range(w):
    if "#" in grid_t[i]:
        w_b.append(i)
ans = []
for i in h_b:
    crt = []
    for j in w_b:
        crt.append(grid[i][j])
    ans.append(crt)
for i in range(len(ans)):
    print(("".join(ans[i])))

-import numpy - -grid = numpy.empty([h, w], str) -white_h = [] -white_w = [] +grid = [] -    grid[i] = list(eval(input())) +    grid.append(list(eval(input()))) +h_b = [] +w_b = [] -    if "#" not in grid[i]: -        white_h.append(i) +    if "#" in grid[i]: +        h_b.append(i) +grid_t = [list(x) for x in zip(*grid)] -    if "#" not in grid[:, i]: -        white_w.append(i) -ans_grid = numpy.empty([h - len(white_h), w - len(white_w)], str) -cnt_h = 0 -for i in range(h): -    if i not in white_h: -        cnt_w = 0 -        for j in range(w): -            if j not in white_w: -                ans_grid[cnt_h, cnt_w] = grid[i, j] -                cnt_w += 1 -        cnt_h += 1 -for i in range(len(ans_grid)): -    print(("".join(ans_grid[i]))) +    if "#" in grid_t[i]: +        w_b.append(i) +ans = [] +for i in h_b: +    crt = [] +    for j in w_b: +        crt.append(grid[i][j]) +    ans.append(crt) +for i in range(len(ans)): +    print(("".join(ans[i])))