

# import numpy as np

# import numpypy as np

import sys

input = sys.stdin.readline



def eprint(*args, **kwargs):

    print(*args, file=sys.stderr, **kwargs)

    return



import math

import string

import fractions

from fractions import Fraction

from fractions import gcd



def lcm(n,m):

    return int(n*m/gcd(n,m))



import re

import array

import copy

import functools

import operator



import collections

import itertools

import bisect

import heapq





from heapq import heappush

from heapq import heappop

from heapq import heappushpop

from heapq import heapify

from heapq import heapreplace



from queue import PriorityQueue as pq



def reduce(p, q):

    common = fractions.gcd(p, q)

    return (p//common , q//common )

# from itertools import accumulate

# from collections import deque



import random





def main():

    H,W = list(map(int, input().strip().split())) # H行 W列

    G=[]

    for i_row in range(H):

        G.append(input().strip())

    eprint("graph G:")

    eprint(G)



    l_flag_row_all_dot_flag=[ 1 for _ in range(H) ]

    for i_row in range(H):

        for j_col in range(W):

            if G[i_row][j_col]!=".":

                l_flag_row_all_dot_flag[i_row]=0





    l_flag_col_all_dot_flag=[ 1 for _ in range(W) ]

    for j_col in range(W):

        for i_row in range(H):

            if G[i_row][j_col]!=".":

                l_flag_col_all_dot_flag[j_col]=0



    for i_row in range(H):

        if l_flag_row_all_dot_flag[i_row]==1:

            continue

        for j_col in range(W):

            if l_flag_col_all_dot_flag[j_col]==1:

                continue

            print(G[i_row][j_col],end="")

        print()













    # for i_row in range(H):      # H is length of row

    #     if G[i_row] == str(["."* W ]):

    #         G.pop(i_row)



    # all_dot_flag=1

    # for j_col in range(W):      # W は列の長さ

    #     for i_row in range(H):  # H は行の長さ

    #         G[i_row][j_col] != "."

    #         failure_flag=0

    #     if all_dot_flag==1:

    #         for ii in range(H):

    #             G.pop()

    return



if __name__ == '__main__':

    main()



# import numpy as np

# import numpypy as np

import sys

input = sys.stdin.readline



def eprint(*args, **kwargs):

    print(*args, file=sys.stderr, **kwargs)

    return



import math

import string

import fractions

from fractions import Fraction

from fractions import gcd



def lcm(n,m):

    return int(n*m/gcd(n,m))



import re

import array

import copy

import functools

import operator



import collections

import itertools

import bisect

import heapq





from heapq import heappush

from heapq import heappop

from heapq import heappushpop

from heapq import heapify

from heapq import heapreplace



from queue import PriorityQueue as pq



def reduce(p, q):

    common = fractions.gcd(p, q)

    return (p//common , q//common )

# from itertools import accumulate

# from collections import deque



from operator import mul

from functools import reduce



def combinations_count(n, r):

    r = min(r, n - r)

    numer = reduce(mul, list(range(n, n - r, -1)), 1)

    denom = reduce(mul, list(range(1, r + 1)), 1)

    return numer // denom



import random





def main():

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

    g = [input().strip() for _ in range(h)]

    gg  = [col for col in zip(*g) if("#" in col)]

    

    eprint("gg ",end=": \n")

    eprint(gg)

    for elem in gg:

        eprint(elem)

        

    gg = [row for row in zip(*gg) if("#" in row)]

    eprint("gg ",end=": \n")

    eprint(gg)

    # for elem in gg:

    #     eprint(elem)

    

    for S in gg:

        print("".join(S))

    return



if __name__ == '__main__':

    main()





# trA  = [list(col) for col in zip(*A)]

# import numpy as np
# import numpypy as np
import sys

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


import math
import string
import fractions
from fractions import Fraction
from fractions import gcd


def lcm(n, m):
    return int(n * m / gcd(n, m))


import re
import array
import copy
import functools
import operator
import collections
import itertools
import bisect
import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq


def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


# from itertools import accumulate
# from collections import deque
import random


def main():
    H, W = list(map(int, input().strip().split()))  # H行 W列
    G = []
    for i_row in range(H):
        G.append(input().strip())
    eprint("graph G:")
    eprint(G)
    l_flag_row_all_dot_flag = [1 for _ in range(H)]
    for i_row in range(H):
        for j_col in range(W):
            if G[i_row][j_col] != ".":
                l_flag_row_all_dot_flag[i_row] = 0
    l_flag_col_all_dot_flag = [1 for _ in range(W)]
    for j_col in range(W):
        for i_row in range(H):
            if G[i_row][j_col] != ".":
                l_flag_col_all_dot_flag[j_col] = 0
    for i_row in range(H):
        if l_flag_row_all_dot_flag[i_row] == 1:
            continue
        for j_col in range(W):
            if l_flag_col_all_dot_flag[j_col] == 1:
                continue
            print(G[i_row][j_col], end="")
        print()
    # for i_row in range(H):      # H is length of row
    #     if G[i_row] == str(["."* W ]):
    #         G.pop(i_row)
    # all_dot_flag=1
    # for j_col in range(W):      # W は列の長さ
    #     for i_row in range(H):  # H は行の長さ
    #         G[i_row][j_col] != "."
    #         failure_flag=0
    #     if all_dot_flag==1:
    #         for ii in range(H):
    #             G.pop()
    return


if __name__ == "__main__":
    main()

# import numpy as np
# import numpypy as np
import sys

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


import math
import string
import fractions
from fractions import Fraction
from fractions import gcd


def lcm(n, m):
    return int(n * m / gcd(n, m))


import re
import array
import copy
import functools
import operator
import collections
import itertools
import bisect
import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq


def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


# from itertools import accumulate
# from collections import deque
from operator import mul
from functools import reduce


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, list(range(n, n - r, -1)), 1)
    denom = reduce(mul, list(range(1, r + 1)), 1)
    return numer // denom


import random


def main():
    h, w = list(map(int, input().strip().split()))
    g = [input().strip() for _ in range(h)]
    gg = [col for col in zip(*g) if ("#" in col)]
    eprint("gg ", end=": \n")
    eprint(gg)
    for elem in gg:
        eprint(elem)
    gg = [row for row in zip(*gg) if ("#" in row)]
    eprint("gg ", end=": \n")
    eprint(gg)
    # for elem in gg:
    #     eprint(elem)
    for S in gg:
        print("".join(S))
    return


if __name__ == "__main__":
    main()
# trA  = [list(col) for col in zip(*A)]

+from operator import mul +from functools import reduce + + +def combinations_count(n, r): +    r = min(r, n - r) +    numer = reduce(mul, list(range(n, n - r, -1)), 1) +    denom = reduce(mul, list(range(1, r + 1)), 1) +    return numer // denom + + -    H, W = list(map(int, input().strip().split()))  # H行 W列 -    G = [] -    for i_row in range(H): -        G.append(input().strip()) -    eprint("graph G:") -    eprint(G) -    l_flag_row_all_dot_flag = [1 for _ in range(H)] -    for i_row in range(H): -        for j_col in range(W): -            if G[i_row][j_col] != ".": -                l_flag_row_all_dot_flag[i_row] = 0 -    l_flag_col_all_dot_flag = [1 for _ in range(W)] -    for j_col in range(W): -        for i_row in range(H): -            if G[i_row][j_col] != ".": -                l_flag_col_all_dot_flag[j_col] = 0 -    for i_row in range(H): -        if l_flag_row_all_dot_flag[i_row] == 1: -            continue -        for j_col in range(W): -            if l_flag_col_all_dot_flag[j_col] == 1: -                continue -            print(G[i_row][j_col], end="") -        print() -    # for i_row in range(H):      # H is length of row -    #     if G[i_row] == str(["."* W ]): -    #         G.pop(i_row) -    # all_dot_flag=1 -    # for j_col in range(W):      # W は列の長さ -    #     for i_row in range(H):  # H は行の長さ -    #         G[i_row][j_col] != "." -    #         failure_flag=0 -    #     if all_dot_flag==1: -    #         for ii in range(H): -    #             G.pop() +    h, w = list(map(int, input().strip().split())) +    g = [input().strip() for _ in range(h)] +    gg = [col for col in zip(*g) if ("#" in col)] +    eprint("gg ", end=": \n") +    eprint(gg) +    for elem in gg: +        eprint(elem) +    gg = [row for row in zip(*gg) if ("#" in row)] +    eprint("gg ", end=": \n") +    eprint(gg) +    # for elem in gg: +    #     eprint(elem) +    for S in gg: +        print("".join(S)) +# trA  = [list(col) for col in zip(*A)]