import numpy as np



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

matrix = np.zeros((h, w), dtype=bool)

for i in range(h):

    row = np.array(list(input()))

    matrix[i, :] = row == "."



for i in range(h)[::-1]:

    if np.all(matrix[i, :]):

        matrix = np.delete(matrix, i, 0)



for i in range(w)[::-1]:

    if np.all(matrix[:, i]):

        matrix = np.delete(matrix, i, 1)



matrix = np.where(matrix, ".", "#")

for row in matrix:

    for e in row:

        print(e, end="")

    print()

# h wの読み込み

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

# 行列作成

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



# #が含まれていない行を削除

[mat.remove(row) for row in mat[::-1] if ("#" not in row)]

# #が含まれている列のインデックスを取得

showCol = [i for i in range(w) if "#" in [row[i] for row in mat]]



# 表示

print(("\n".join(["".join([row[c] for c in showCol]) for row in mat])))

import numpy as np

h, w = tuple(map(int, input().split()))
matrix = np.zeros((h, w), dtype=bool)
for i in range(h):
    row = np.array(list(input()))
    matrix[i, :] = row == "."
for i in range(h)[::-1]:
    if np.all(matrix[i, :]):
        matrix = np.delete(matrix, i, 0)
for i in range(w)[::-1]:
    if np.all(matrix[:, i]):
        matrix = np.delete(matrix, i, 1)
matrix = np.where(matrix, ".", "#")
for row in matrix:
    for e in row:
        print(e, end="")
    print()

# h wの読み込み
h, w = list(map(int, input().split()))
# 行列作成
mat = [eval(input()) for _ in range(h)]
# #が含まれていない行を削除
[mat.remove(row) for row in mat[::-1] if ("#" not in row)]
# #が含まれている列のインデックスを取得
showCol = [i for i in range(w) if "#" in [row[i] for row in mat]]
# 表示
print(("\n".join(["".join([row[c] for c in showCol]) for row in mat])))

-import numpy as np - -h, w = tuple(map(int, input().split())) -matrix = np.zeros((h, w), dtype=bool) -for i in range(h): -    row = np.array(list(input())) -    matrix[i, :] = row == "." -for i in range(h)[::-1]: -    if np.all(matrix[i, :]): -        matrix = np.delete(matrix, i, 0) -for i in range(w)[::-1]: -    if np.all(matrix[:, i]): -        matrix = np.delete(matrix, i, 1) -matrix = np.where(matrix, ".", "#") -for row in matrix: -    for e in row: -        print(e, end="") -    print() +# h wの読み込み +h, w = list(map(int, input().split())) +# 行列作成 +mat = [eval(input()) for _ in range(h)] +# #が含まれていない行を削除 +[mat.remove(row) for row in mat[::-1] if ("#" not in row)] +# #が含まれている列のインデックスを取得 +showCol = [i for i in range(w) if "#" in [row[i] for row in mat]] +# 表示 +print(("\n".join(["".join([row[c] for c in showCol]) for row in mat])))