# ABC107B - Grid Compression

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

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

row = [False] * h

col = [False] * w



for i in range(h):

    for j in range(w):

        if data[i][j] == "#":

            row[i] = True

            col[j] = True



for i in range(h):

    if row[i] == True:

        for j in range(w):

            if col[j] == True:

                print(data[i][j], end="")

        print()

# ABC107B - Grid Compression

def main():

    H, W, *A = open(0).read().split()

    H, W = int(H), int(W)

    X, Y = [0] * H, [0] * W

    for i, a in enumerate(A):

        for j, x in enumerate(a):

            if x == "#":

                X[i], Y[j] = 1, 1

    ans = []

    for i, x in enumerate(X):

        cur = ""

        for j, y in enumerate(Y):

            if x and y:

                cur += A[i][j]

        if cur:

            ans.append(cur)

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





if __name__ == "__main__":

    main()

# ABC107B - Grid Compression
h, w = list(map(int, input().rstrip().split()))
data = [input().rstrip() for _ in range(h)]
row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if data[i][j] == "#":
            row[i] = True
            col[j] = True
for i in range(h):
    if row[i] == True:
        for j in range(w):
            if col[j] == True:
                print(data[i][j], end="")
        print()

# ABC107B - Grid Compression
def main():
    H, W, *A = open(0).read().split()
    H, W = int(H), int(W)
    X, Y = [0] * H, [0] * W
    for i, a in enumerate(A):
        for j, x in enumerate(a):
            if x == "#":
                X[i], Y[j] = 1, 1
    ans = []
    for i, x in enumerate(X):
        cur = ""
        for j, y in enumerate(Y):
            if x and y:
                cur += A[i][j]
        if cur:
            ans.append(cur)
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

-h, w = list(map(int, input().rstrip().split())) -data = [input().rstrip() for _ in range(h)] -row = [False] * h -col = [False] * w -for i in range(h): -    for j in range(w): -        if data[i][j] == "#": -            row[i] = True -            col[j] = True -for i in range(h): -    if row[i] == True: -        for j in range(w): -            if col[j] == True: -                print(data[i][j], end="") -        print() +def main(): +    H, W, *A = open(0).read().split() +    H, W = int(H), int(W) +    X, Y = [0] * H, [0] * W +    for i, a in enumerate(A): +        for j, x in enumerate(a): +            if x == "#": +                X[i], Y[j] = 1, 1 +    ans = [] +    for i, x in enumerate(X): +        cur = "" +        for j, y in enumerate(Y): +            if x and y: +                cur += A[i][j] +        if cur: +            ans.append(cur) +    print(*ans, sep="\n") + + +if __name__ == "__main__": +    main()