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

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

good_r = [False for _ in range(h)]

good_c = [False for _ in range(w)]



for i in range(h):

    for j in range(w):

        if a[i][j] == '#':

            good_r[i] = True

            good_c[j] = True



for i in range(h):

    if good_r[i]:

        string = ''

        for j in range(w):

            if good_c[j]:

                string += a[i][j]

        if len(string) > 0:

            print(string)
def main():

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

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



    show_r = []

    show_c = []



    for r, row in enumerate(a):

        show_r.append(any(c == '#' for c in row))



    for c, col in enumerate(zip(*a)):

        show_c.append(any(c == '#' for c in col))



    ans = []

    for r in range(H):

        t = ''

        for c in range(W):

            if show_r[r] and show_c[c]:

                t += a[r][c]

        if t:

            ans.append(t)



    print(*ans, sep='\n')





if __name__ == '__main__':

    main()



# import sys

#

# sys.setrecursionlimit(10 ** 7)

#

# input = sys.stdin.readline

# rstrip()

# int(input())

# map(int, input().split())

h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
good_r = [False for _ in range(h)]
good_c = [False for _ in range(w)]
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            good_r[i] = True
            good_c[j] = True
for i in range(h):
    if good_r[i]:
        string = ""
        for j in range(w):
            if good_c[j]:
                string += a[i][j]
        if len(string) > 0:
            print(string)

def main():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]
    show_r = []
    show_c = []
    for r, row in enumerate(a):
        show_r.append(any(c == "#" for c in row))
    for c, col in enumerate(zip(*a)):
        show_c.append(any(c == "#" for c in col))
    ans = []
    for r in range(H):
        t = ""
        for c in range(W):
            if show_r[r] and show_c[c]:
                t += a[r][c]
        if t:
            ans.append(t)
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

-h, w = list(map(int, input().split())) -a = [list(eval(input())) for _ in range(h)] -good_r = [False for _ in range(h)] -good_c = [False for _ in range(w)] -for i in range(h): -    for j in range(w): -        if a[i][j] == "#": -            good_r[i] = True -            good_c[j] = True -for i in range(h): -    if good_r[i]: -        string = "" -        for j in range(w): -            if good_c[j]: -                string += a[i][j] -        if len(string) > 0: -            print(string) +def main(): +    H, W = map(int, input().split()) +    a = [input() for _ in range(H)] +    show_r = [] +    show_c = [] +    for r, row in enumerate(a): +        show_r.append(any(c == "#" for c in row)) +    for c, col in enumerate(zip(*a)): +        show_c.append(any(c == "#" for c in col)) +    ans = [] +    for r in range(H): +        t = "" +        for c in range(W): +            if show_r[r] and show_c[c]: +                t += a[r][c] +        if t: +            ans.append(t) +    print(*ans, sep="\n") + + +if __name__ == "__main__": +    main() +# import sys +# +# sys.setrecursionlimit(10 ** 7) +# +# input = sys.stdin.readline +# rstrip() +# int(input()) +# map(int, input().split())