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

matrix=[list(map(str,input().split())) for i in range(H)]

count_delete_H=0

count_delete_W=0



for i in range(H):

  matrix[i-count_delete_H]=list(*matrix[i-count_delete_H])

  if(matrix[i-count_delete_H].count('#')==0):

    del matrix[i-count_delete_H]

    count_delete_H+=1

    

matrix_t = [list(x) for x in zip(*matrix)]

for i in range(W):

  if(matrix_t[i-count_delete_W].count('#')==0):

    del matrix_t[i-count_delete_W]

    count_delete_W+=1

    

matrix_tt = [list(x) for x in zip(*matrix_t)]

for i in range(H-count_delete_H):

  for j in range(W-count_delete_W):

    print(matrix_tt[i][j],end='')

  print('')

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

HW = [eval(input()) for _ in range(H)]

#print(HW)

#黒がない行は削除して転置,*で文字列を一文字ずつに分解、joinで再結合

HW = ["".join(hw) for hw in zip(*HW) if hw.count("#") > 0]

#転置した後の黒がない行（元の行列の列に対応する）は削除して転置（元の行列に戻る）

HW = ["".join(hw) for hw in zip(*HW) if hw.count("#") > 0]

print(("\n".join(HW)))#改行を伴って結合
H, W = map(int, input().split())
matrix = [list(map(str, input().split())) for i in range(H)]
count_delete_H = 0
count_delete_W = 0
for i in range(H):
    matrix[i - count_delete_H] = list(*matrix[i - count_delete_H])
    if matrix[i - count_delete_H].count("#") == 0:
        del matrix[i - count_delete_H]
        count_delete_H += 1
matrix_t = [list(x) for x in zip(*matrix)]
for i in range(W):
    if matrix_t[i - count_delete_W].count("#") == 0:
        del matrix_t[i - count_delete_W]
        count_delete_W += 1
matrix_tt = [list(x) for x in zip(*matrix_t)]
for i in range(H - count_delete_H):
    for j in range(W - count_delete_W):
        print(matrix_tt[i][j], end="")
    print("")

H, W = list(map(int, input().split()))
HW = [eval(input()) for _ in range(H)]
# print(HW)
# 黒がない行は削除して転置,*で文字列を一文字ずつに分解、joinで再結合
HW = ["".join(hw) for hw in zip(*HW) if hw.count("#") > 0]
# 転置した後の黒がない行（元の行列の列に対応する）は削除して転置（元の行列に戻る）
HW = ["".join(hw) for hw in zip(*HW) if hw.count("#") > 0]
print(("\n".join(HW)))  # 改行を伴って結合

-H, W = map(int, input().split()) -matrix = [list(map(str, input().split())) for i in range(H)] -count_delete_H = 0 -count_delete_W = 0 -for i in range(H): -    matrix[i - count_delete_H] = list(*matrix[i - count_delete_H]) -    if matrix[i - count_delete_H].count("#") == 0: -        del matrix[i - count_delete_H] -        count_delete_H += 1 -matrix_t = [list(x) for x in zip(*matrix)] -for i in range(W): -    if matrix_t[i - count_delete_W].count("#") == 0: -        del matrix_t[i - count_delete_W] -        count_delete_W += 1 -matrix_tt = [list(x) for x in zip(*matrix_t)] -for i in range(H - count_delete_H): -    for j in range(W - count_delete_W): -        print(matrix_tt[i][j], end="") -    print("") +H, W = list(map(int, input().split())) +HW = [eval(input()) for _ in range(H)] +# print(HW) +# 黒がない行は削除して転置,*で文字列を一文字ずつに分解、joinで再結合 +HW = ["".join(hw) for hw in zip(*HW) if hw.count("#") > 0] +# 転置した後の黒がない行（元の行列の列に対応する）は削除して転置（元の行列に戻る） +HW = ["".join(hw) for hw in zip(*HW) if hw.count("#") > 0] +print(("\n".join(HW)))  # 改行を伴って結合