# Use numpy if you use column operation

import numpy as np

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



# Get grid colors

gird_colors = np.array([])

for _ in range(h):

    tmp_row = np.array(list(eval(input())))

    if "#" in tmp_row: # If the row includes black

        gird_colors = np.concatenate((gird_colors, tmp_row))

gird_colors = gird_colors.reshape(-1, w)



# Search and delete white line

del_count = 0

for wi in range(w):

    if "#" not in gird_colors[:, wi - del_count]:

        gird_colors = np.delete(gird_colors, wi - del_count, 1)

        del_count += 1



# Print result

for line_val in gird_colors:

    print(("".join(line_val))) 
h, w = list(map(int, input().split()))

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



# Filtering the data if any "#" are existed in the each row or col

# Usage: filter(lambda row: <filtering condition>, grid or zip(*grid)) 

# If true, the row is not be deleted

# (Do not use if statement!)

row_compressed_grid = list([row for row in grid if any(x == "#" for x in row)])

compressed_grid = list([col for col in zip(*row_compressed_grid) if any(x == "#" for x in col)])

# list -> string and out

for row in zip(*compressed_grid):

    print(("".join(row)))
# Use numpy if you use column operation
import numpy as np

h, w = list(map(int, input().split()))
# Get grid colors
gird_colors = np.array([])
for _ in range(h):
    tmp_row = np.array(list(eval(input())))
    if "#" in tmp_row:  # If the row includes black
        gird_colors = np.concatenate((gird_colors, tmp_row))
gird_colors = gird_colors.reshape(-1, w)
# Search and delete white line
del_count = 0
for wi in range(w):
    if "#" not in gird_colors[:, wi - del_count]:
        gird_colors = np.delete(gird_colors, wi - del_count, 1)
        del_count += 1
# Print result
for line_val in gird_colors:
    print(("".join(line_val)))

h, w = list(map(int, input().split()))
grid = [list(eval(input())) for _ in range(h)]
# Filtering the data if any "#" are existed in the each row or col
# Usage: filter(lambda row: <filtering condition>, grid or zip(*grid))
# If true, the row is not be deleted
# (Do not use if statement!)
row_compressed_grid = list([row for row in grid if any(x == "#" for x in row)])
compressed_grid = list(
    [col for col in zip(*row_compressed_grid) if any(x == "#" for x in col)]
)
# list -> string and out
for row in zip(*compressed_grid):
    print(("".join(row)))

-# Use numpy if you use column operation -import numpy as np - -# Get grid colors -gird_colors = np.array([]) -for _ in range(h): -    tmp_row = np.array(list(eval(input()))) -    if "#" in tmp_row:  # If the row includes black -        gird_colors = np.concatenate((gird_colors, tmp_row)) -gird_colors = gird_colors.reshape(-1, w) -# Search and delete white line -del_count = 0 -for wi in range(w): -    if "#" not in gird_colors[:, wi - del_count]: -        gird_colors = np.delete(gird_colors, wi - del_count, 1) -        del_count += 1 -# Print result -for line_val in gird_colors: -    print(("".join(line_val))) +grid = [list(eval(input())) for _ in range(h)] +# Filtering the data if any "#" are existed in the each row or col +# Usage: filter(lambda row: <filtering condition>, grid or zip(*grid)) +# If true, the row is not be deleted +# (Do not use if statement!) +row_compressed_grid = list([row for row in grid if any(x == "#" for x in row)]) +compressed_grid = list( +    [col for col in zip(*row_compressed_grid) if any(x == "#" for x in col)] +) +# list -> string and out +for row in zip(*compressed_grid): +    print(("".join(row)))