import numpy as np,sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def S(): return sys.stdin.readline().rstrip()

H,W = LI()

a = np.array([[s for s in S()] for _ in range(H)])

a = a[(a=='#').any(axis=1)]

a = a.T

a = a[(a=='#').any(axis=1)]

a = a.T.tolist()

for x in a:

    print(*x,sep='')

import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def S(): return sys.stdin.readline().rstrip()

H,W = LI()

a = [S() for _ in range(H)]

a2,a3 = [],[]

for x in a:

    if '#' in x:

        a2.append(x)

for y in zip(*a2):

    if '#' in y:

        a3.append(y)

for z in zip(*a3):

    print(*z,sep='')

import numpy as np, sys


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


def S():
    return sys.stdin.readline().rstrip()


H, W = LI()
a = np.array([[s for s in S()] for _ in range(H)])
a = a[(a == "#").any(axis=1)]
a = a.T
a = a[(a == "#").any(axis=1)]
a = a.T.tolist()
for x in a:
    print(*x, sep="")

import sys


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


def S():
    return sys.stdin.readline().rstrip()


H, W = LI()
a = [S() for _ in range(H)]
a2, a3 = [], []
for x in a:
    if "#" in x:
        a2.append(x)
for y in zip(*a2):
    if "#" in y:
        a3.append(y)
for z in zip(*a3):
    print(*z, sep="")

-import numpy as np, sys +import sys -a = np.array([[s for s in S()] for _ in range(H)]) -a = a[(a == "#").any(axis=1)] -a = a.T -a = a[(a == "#").any(axis=1)] -a = a.T.tolist() +a = [S() for _ in range(H)] +a2, a3 = [], [] -    print(*x, sep="") +    if "#" in x: +        a2.append(x) +for y in zip(*a2): +    if "#" in y: +        a3.append(y) +for z in zip(*a3): +    print(*z, sep="")