import numpy as np



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

al = list(list(input()) for _ in range(h))

al_n = np.array(al)

row = [0]*w

col = [0]*h

for i in range(h):

    for j in range(w):

        if al_n[i][j] == '.':

            row[j] += 1

            col[i] += 1

row_ = []

col_ = []

for i in range(w):

    if row[i] == h:

        row_.append(i)



for j in range(h):

    if col[j] == w:

        col_.append(j)



if len(col_) > 0:

    al_n = np.delete(al_n, col_, axis=0)



if len(row_) > 0:

    al_n = np.delete(al_n, row_, axis=1)



for a in al_n:

    print(*a, sep='')

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

al = list(list(input()) for _ in range(h))

row = [0]*w

col = [0]*h



for i in range(h):

    for j in range(w):

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

            col[i] += 1

            row[j] += 1

ans = []

w_len = len(row) - row.count(0)

for i in range(h):

    tmp = ''

    if col[i] != 0:

        for j in range(w):

            if row[j] != 0:

                tmp += al[i][j]

        ans.append(tmp)



for a in ans:

    print(*a, sep='')

import numpy as np

h, w = map(int, input().split())
al = list(list(input()) for _ in range(h))
al_n = np.array(al)
row = [0] * w
col = [0] * h
for i in range(h):
    for j in range(w):
        if al_n[i][j] == ".":
            row[j] += 1
            col[i] += 1
row_ = []
col_ = []
for i in range(w):
    if row[i] == h:
        row_.append(i)
for j in range(h):
    if col[j] == w:
        col_.append(j)
if len(col_) > 0:
    al_n = np.delete(al_n, col_, axis=0)
if len(row_) > 0:
    al_n = np.delete(al_n, row_, axis=1)
for a in al_n:
    print(*a, sep="")

h, w = map(int, input().split())
al = list(list(input()) for _ in range(h))
row = [0] * w
col = [0] * h
for i in range(h):
    for j in range(w):
        if al[i][j] == "#":
            col[i] += 1
            row[j] += 1
ans = []
w_len = len(row) - row.count(0)
for i in range(h):
    tmp = ""
    if col[i] != 0:
        for j in range(w):
            if row[j] != 0:
                tmp += al[i][j]
        ans.append(tmp)
for a in ans:
    print(*a, sep="")

-import numpy as np - -al_n = np.array(al) -        if al_n[i][j] == ".": +        if al[i][j] == "#": +            col[i] += 1 -            col[i] += 1 -row_ = [] -col_ = [] -for i in range(w): -    if row[i] == h: -        row_.append(i) -for j in range(h): -    if col[j] == w: -        col_.append(j) -if len(col_) > 0: -    al_n = np.delete(al_n, col_, axis=0) -if len(row_) > 0: -    al_n = np.delete(al_n, row_, axis=1) -for a in al_n: +ans = [] +w_len = len(row) - row.count(0) +for i in range(h): +    tmp = "" +    if col[i] != 0: +        for j in range(w): +            if row[j] != 0: +                tmp += al[i][j] +        ans.append(tmp) +for a in ans: