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

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

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)))
import sys



stdin = sys.stdin



ns = lambda : stdin.readline().rstrip()

ni = lambda : int(ns())

na = lambda : list(map(int, stdin.readline().split()))



def main():

  h, w = na()

  a = [ns() for _ in range(h)]

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

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

  print(("\n".join(a)))



main()
H, W = list(map(int, input().split()))
HW = [eval(input()) for _ in range(H)]
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)))

import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    h, w = na()
    a = [ns() for _ in range(h)]
    a = ["".join(hw) for hw in zip(*a) if hw.count("#") > 0]
    a = ["".join(hw) for hw in zip(*a) if hw.count("#") > 0]
    print(("\n".join(a)))


main()

-H, W = list(map(int, input().split())) -HW = [eval(input()) for _ in range(H)] -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))) +import sys + +stdin = sys.stdin +ns = lambda: stdin.readline().rstrip() +ni = lambda: int(ns()) +na = lambda: list(map(int, stdin.readline().split())) + + +def main(): +    h, w = na() +    a = [ns() for _ in range(h)] +    a = ["".join(hw) for hw in zip(*a) if hw.count("#") > 0] +    a = ["".join(hw) for hw in zip(*a) if hw.count("#") > 0] +    print(("\n".join(a))) + + +main()