Imports System.Collections.Generic
Imports System.Console
Imports System.Math

Module Program
    Sub Main()
        Dim H As Integer = NextInt()
        Dim W As Integer = NextInt()

        Dim a As String() = New String(H - 1) {}
        For i As Integer = 0 To H - 1
            a(i) = ReadLine()
        Next

        For j As Integer = W - 1 To 0 Step -1
            Dim flg As Boolean = False
            For i As Integer = 0 To H - 1
                If a(i)(j) = "#" Then flg = True
            Next

            If Not flg Then
                For i As Integer = 0 To H - 1
                    a(i) = Left(a(i), j) & Mid(a(i), j + 2)
                Next
            End If
        Next

        For i As Integer = 0 To H - 1
            If a(i).Contains("#") Then
                WriteLine(a(i))
            End If
        Next
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
