from functools import reduce

from decimal import *

from operator import mul



def main():

    h, w = input_list()

    masu = []

    for _ in range(h):

        line = list(eval(input()))

        masu.append(line)

    rows = [False] * h

    cols = [False] * w

    for i, m in enumerate(masu):

        for j, v in enumerate(m):

            if v == "#":

                rows[i] = True

                cols[j] = True

    for i, m in enumerate(masu):

        if rows[i] is False:

            continue

        a = ''

        for j, v in enumerate(m):

            if cols[j] is False:

                continue

            a += v

        print(a)



def count_tento(l, cur):

    count = 0

    for v in l:

        if v > cur:

            count += 1

    return count



def input_list():

    return list(map(int, input().split()))



def prime_factorize(n):

    a = []

    while n % 2 == 0:

        a.append(2)

        n //= 2

    f = 3

    while f * f <= n:

        if n % f == 0:

            a.append(f)

            n //= f

        else:

            f += 2

    if n != 1:

        a.append(n)

    return a



if __name__ == '__main__':

    main()

# import sys

# input = sys.stdin.readline

import collections

import itertools



def main():

    h, w = input_list()

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

    ans = []

    blacks = [False] * w

    for m in maze:

        for i, v in enumerate(m):

            if v == "#":

                blacks[i] = True

    for m in maze:

        f = True

        new_row = []

        for i, b in enumerate(blacks):

            if b:

                new_row.append(m[i])

        for i, v in enumerate(new_row):

            if v == "#":

                f = False

                break

        if f:

            continue

        ans.append(new_row)

    for a in ans:

        print(("".join(a)))





def input_list():

    return list(map(int, input().split()))





def input_list_str():

    return list(map(str, input().split()))





if __name__ == "__main__":

    main()

from functools import reduce
from decimal import *
from operator import mul


def main():
    h, w = input_list()
    masu = []
    for _ in range(h):
        line = list(eval(input()))
        masu.append(line)
    rows = [False] * h
    cols = [False] * w
    for i, m in enumerate(masu):
        for j, v in enumerate(m):
            if v == "#":
                rows[i] = True
                cols[j] = True
    for i, m in enumerate(masu):
        if rows[i] is False:
            continue
        a = ""
        for j, v in enumerate(m):
            if cols[j] is False:
                continue
            a += v
        print(a)


def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count


def input_list():
    return list(map(int, input().split()))


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


if __name__ == "__main__":
    main()

# import sys
# input = sys.stdin.readline
import collections
import itertools


def main():
    h, w = input_list()
    maze = [list(eval(input())) for _ in range(h)]
    ans = []
    blacks = [False] * w
    for m in maze:
        for i, v in enumerate(m):
            if v == "#":
                blacks[i] = True
    for m in maze:
        f = True
        new_row = []
        for i, b in enumerate(blacks):
            if b:
                new_row.append(m[i])
        for i, v in enumerate(new_row):
            if v == "#":
                f = False
                break
        if f:
            continue
        ans.append(new_row)
    for a in ans:
        print(("".join(a)))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

-from functools import reduce -from decimal import * -from operator import mul +# import sys +# input = sys.stdin.readline +import collections +import itertools -    masu = [] -    for _ in range(h): -        line = list(eval(input())) -        masu.append(line) -    rows = [False] * h -    cols = [False] * w -    for i, m in enumerate(masu): -        for j, v in enumerate(m): +    maze = [list(eval(input())) for _ in range(h)] +    ans = [] +    blacks = [False] * w +    for m in maze: +        for i, v in enumerate(m): -                rows[i] = True -                cols[j] = True -    for i, m in enumerate(masu): -        if rows[i] is False: +                blacks[i] = True +    for m in maze: +        f = True +        new_row = [] +        for i, b in enumerate(blacks): +            if b: +                new_row.append(m[i]) +        for i, v in enumerate(new_row): +            if v == "#": +                f = False +                break +        if f: -        a = "" -        for j, v in enumerate(m): -            if cols[j] is False: -                continue -            a += v -        print(a) - - -def count_tento(l, cur): -    count = 0 -    for v in l: -        if v > cur: -            count += 1 -    return count +        ans.append(new_row) +    for a in ans: +        print(("".join(a))) -def prime_factorize(n): -    a = [] -    while n % 2 == 0: -        a.append(2) -        n //= 2 -    f = 3 -    while f * f <= n: -        if n % f == 0: -            a.append(f) -            n //= f -        else: -            f += 2 -    if n != 1: -        a.append(n) -    return a +def input_list_str(): +    return list(map(str, input().split()))