import numpy

H, W = [int(i) for i in input().split()]

A = numpy.array([list(input().strip()) for _ in range(H)])



row_space = []

col_space = []



for k, row in enumerate(A):

    if '#' not in row:

        row_space.append(k)



A_rot = numpy.rot90(A, k=-1)

for k, row in enumerate(A_rot):

    if '#' not in row:

        col_space.append(k)



A = numpy.delete(A, row_space, axis=0)

A = numpy.delete(A, col_space, axis=1)

ans = '\n'.join([''.join(row) for row in A])

print(ans)
def rotate_clockwise(matrix):

    tmp = list(map(list, list(zip(*matrix))))[::-1]

    return list(''.join(row) for row in tmp)

    # 文字列のリストを入れるので文字列のリストで返す





def rotate_counterclockwise(matrix):

    tmp = list([list(x[::-1]) for x in zip(*matrix)])

    return list(''.join(row) for row in tmp)

    # 文字列のリストを入れるので文字列のリストで返す





H, W = [int(i) for i in input().split()]

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



row_remove_count = 0

while '.' * W in A:

    A.remove('.' * W)  # 行まるごと白なら、回数を記録して除く

    row_remove_count += 1



A = rotate_clockwise(A)  # 反時計回りに回す

while '.' * (H - row_remove_count) in A:

    A.remove('.' * (H - row_remove_count))



A = rotate_counterclockwise(A)  # 時計回りに回して元に戻す

print(('\n'.join(A)))
import numpy

H, W = [int(i) for i in input().split()]
A = numpy.array([list(input().strip()) for _ in range(H)])
row_space = []
col_space = []
for k, row in enumerate(A):
    if "#" not in row:
        row_space.append(k)
A_rot = numpy.rot90(A, k=-1)
for k, row in enumerate(A_rot):
    if "#" not in row:
        col_space.append(k)
A = numpy.delete(A, row_space, axis=0)
A = numpy.delete(A, col_space, axis=1)
ans = "\n".join(["".join(row) for row in A])
print(ans)

def rotate_clockwise(matrix):
    tmp = list(map(list, list(zip(*matrix))))[::-1]
    return list("".join(row) for row in tmp)
    # 文字列のリストを入れるので文字列のリストで返す


def rotate_counterclockwise(matrix):
    tmp = list([list(x[::-1]) for x in zip(*matrix)])
    return list("".join(row) for row in tmp)
    # 文字列のリストを入れるので文字列のリストで返す


H, W = [int(i) for i in input().split()]
A = [eval(input()) for _ in range(H)]
row_remove_count = 0
while "." * W in A:
    A.remove("." * W)  # 行まるごと白なら、回数を記録して除く
    row_remove_count += 1
A = rotate_clockwise(A)  # 反時計回りに回す
while "." * (H - row_remove_count) in A:
    A.remove("." * (H - row_remove_count))
A = rotate_counterclockwise(A)  # 時計回りに回して元に戻す
print(("\n".join(A)))

-import numpy +def rotate_clockwise(matrix): +    tmp = list(map(list, list(zip(*matrix))))[::-1] +    return list("".join(row) for row in tmp) +    # 文字列のリストを入れるので文字列のリストで返す + + +def rotate_counterclockwise(matrix): +    tmp = list([list(x[::-1]) for x in zip(*matrix)]) +    return list("".join(row) for row in tmp) +    # 文字列のリストを入れるので文字列のリストで返す + -A = numpy.array([list(input().strip()) for _ in range(H)]) -row_space = [] -col_space = [] -for k, row in enumerate(A): -    if "#" not in row: -        row_space.append(k) -A_rot = numpy.rot90(A, k=-1) -for k, row in enumerate(A_rot): -    if "#" not in row: -        col_space.append(k) -A = numpy.delete(A, row_space, axis=0) -A = numpy.delete(A, col_space, axis=1) -ans = "\n".join(["".join(row) for row in A]) -print(ans) +A = [eval(input()) for _ in range(H)] +row_remove_count = 0 +while "." * W in A: +    A.remove("." * W)  # 行まるごと白なら、回数を記録して除く +    row_remove_count += 1 +A = rotate_clockwise(A)  # 反時計回りに回す +while "." * (H - row_remove_count) in A: +    A.remove("." * (H - row_remove_count)) +A = rotate_counterclockwise(A)  # 時計回りに回して元に戻す +print(("\n".join(A)))