import numpy as np



inputs = input().replace("\n", "")

H, W = list(map(int, inputs.split(" ")))



lines = np.asarray([list(input().replace("\n", "")) for h in range(H)])



h_indexs, w_indexs = list(map(set, np.where(lines == "#")))



outlines = lines[list(h_indexs), :][:, list(w_indexs)]

for outline in outlines:

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



H, W = list(map(int, input().split(" ")))



lines = np.asarray([list(input().replace("\n", "")) for h in range(H)])



h_indexs, w_indexs = list(map(set, np.where(lines == "#")))



outlines = lines[list(h_indexs), :][:, list(w_indexs)]

for outline in outlines:

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

inputs = input().replace("\n", "")
H, W = list(map(int, inputs.split(" ")))
lines = np.asarray([list(input().replace("\n", "")) for h in range(H)])
h_indexs, w_indexs = list(map(set, np.where(lines == "#")))
outlines = lines[list(h_indexs), :][:, list(w_indexs)]
for outline in outlines:
    print("".join(outline))

import numpy as np

H, W = list(map(int, input().split(" ")))
lines = np.asarray([list(input().replace("\n", "")) for h in range(H)])
h_indexs, w_indexs = list(map(set, np.where(lines == "#")))
outlines = lines[list(h_indexs), :][:, list(w_indexs)]
for outline in outlines:
    print(("".join(outline)))

-inputs = input().replace("\n", "") -H, W = list(map(int, inputs.split(" "))) +H, W = list(map(int, input().split(" "))) -    print("".join(outline)) +    print(("".join(outline)))