def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10**7)

    from collections import Counter, deque

    #from collections import defaultdict

    from itertools import combinations, permutations, accumulate, groupby, product

    from bisect import bisect_left,bisect_right

    from heapq import heapify, heappop, heappush

    from math import floor, ceil

    #from operator import itemgetter



    #inf = 10**17

    #mod = 10**9 + 7



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

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

    tate = []

    yoko = []

    for i in range(h):

        if '#' not in a[i]:

            yoko.append(i)

    for i in range(w):

        for j in range(h):

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

                break

        else:

            tate.append(i)

    res = []

    for i in range(h):

        temp = []

        if i in yoko:

            continue

        for j in range(w):

            if j in tate:

                continue

            temp.append(a[i][j])

        res.append(temp)

    for i in res:

        print((''.join(i)))



if __name__ == '__main__':

    main()
### ABC107 B - Grid Compression

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

grid = [[x for x in str(eval(input()))] for _ in range(h)]



del_h = [False] * h

del_w = [False] * w



for i in range(h):

  if grid[i].count('#') == 0:

    del_h[i] = True



for j in range(w):

  del_w[j] = True

  for i in range(h):

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

      del_w[j] = False

      break



for i in range(h):

  if del_h[i]: continue

  row = ''.join([grid[i][j] for j in range(w) if not del_w[j]])

  print(row)

def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque

    # from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left, bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil

    # from operator import itemgetter
    # inf = 10**17
    # mod = 10**9 + 7
    h, w = list(map(int, input().split()))
    a = [list(input().rstrip()) for _ in range(h)]
    tate = []
    yoko = []
    for i in range(h):
        if "#" not in a[i]:
            yoko.append(i)
    for i in range(w):
        for j in range(h):
            if a[j][i] == "#":
                break
        else:
            tate.append(i)
    res = []
    for i in range(h):
        temp = []
        if i in yoko:
            continue
        for j in range(w):
            if j in tate:
                continue
            temp.append(a[i][j])
        res.append(temp)
    for i in res:
        print(("".join(i)))


if __name__ == "__main__":
    main()

### ABC107 B - Grid Compression
h, w = list(map(int, input().split()))
grid = [[x for x in str(eval(input()))] for _ in range(h)]
del_h = [False] * h
del_w = [False] * w
for i in range(h):
    if grid[i].count("#") == 0:
        del_h[i] = True
for j in range(w):
    del_w[j] = True
    for i in range(h):
        if grid[i][j] == "#":
            del_w[j] = False
            break
for i in range(h):
    if del_h[i]:
        continue
    row = "".join([grid[i][j] for j in range(w) if not del_w[j]])
    print(row)

-def main(): -    import sys - -    input = sys.stdin.readline -    sys.setrecursionlimit(10**7) -    from collections import Counter, deque - -    # from collections import defaultdict -    from itertools import combinations, permutations, accumulate, groupby, product -    from bisect import bisect_left, bisect_right -    from heapq import heapify, heappop, heappush -    from math import floor, ceil - -    # from operator import itemgetter -    # inf = 10**17 -    # mod = 10**9 + 7 -    h, w = list(map(int, input().split())) -    a = [list(input().rstrip()) for _ in range(h)] -    tate = [] -    yoko = [] +### ABC107 B - Grid Compression +h, w = list(map(int, input().split())) +grid = [[x for x in str(eval(input()))] for _ in range(h)] +del_h = [False] * h +del_w = [False] * w +for i in range(h): +    if grid[i].count("#") == 0: +        del_h[i] = True +for j in range(w): +    del_w[j] = True -        if "#" not in a[i]: -            yoko.append(i) -    for i in range(w): -        for j in range(h): -            if a[j][i] == "#": -                break -        else: -            tate.append(i) -    res = [] -    for i in range(h): -        temp = [] -        if i in yoko: -            continue -        for j in range(w): -            if j in tate: -                continue -            temp.append(a[i][j]) -        res.append(temp) -    for i in res: -        print(("".join(i))) - - -if __name__ == "__main__": -    main() +        if grid[i][j] == "#": +            del_w[j] = False +            break +for i in range(h): +    if del_h[i]: +        continue +    row = "".join([grid[i][j] for j in range(w) if not del_w[j]]) +    print(row)