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

A = [input() for h in range(H)]

row = H*[False]

col = W*[False]



for h in range(H):

  for w in range(W):

    if A[h][w]=="#":

      row[h] = True

      col[w] = True



for h in range(H):

  if row[h]:

    for w in range(W):

      if col[w]:

        print(A[h][w],end="")

    print()

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

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

A = list([a for a in A if any(x=='#' for x in a)]) 

A = list([a for a in zip(*A) if any(x=='#' for x in a)])



for a in zip(*A):

  print(("".join(a)))
H, W = map(int, input().split())
A = [input() for h in range(H)]
row = H * [False]
col = W * [False]
for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            row[h] = True
            col[w] = True
for h in range(H):
    if row[h]:
        for w in range(W):
            if col[w]:
                print(A[h][w], end="")
        print()

H, W = list(map(int, input().split()))
A = [eval(input()) for _ in range(H)]
A = list([a for a in A if any(x == "#" for x in a)])
A = list([a for a in zip(*A) if any(x == "#" for x in a)])
for a in zip(*A):
    print(("".join(a)))

-H, W = map(int, input().split()) -A = [input() for h in range(H)] -row = H * [False] -col = W * [False] -for h in range(H): -    for w in range(W): -        if A[h][w] == "#": -            row[h] = True -            col[w] = True -for h in range(H): -    if row[h]: -        for w in range(W): -            if col[w]: -                print(A[h][w], end="") -        print() +H, W = list(map(int, input().split())) +A = [eval(input()) for _ in range(H)] +A = list([a for a in A if any(x == "#" for x in a)]) +A = list([a for a in zip(*A) if any(x == "#" for x in a)]) +for a in zip(*A): +    print(("".join(a)))