Imports System.Collections.Generic
Imports System.Console

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

        Dim a As String(,) = New String(H, W) {}

        For i As Integer = 0 To H - 1
            For j As Integer = 0 To W - 1
                a(i, j) = Chr(Read())
            Next
            ReadLine()
        Next

        For j As Integer = 0 To W - 1
            Dim flg As Boolean = False
            For i As Integer = 0 To H - 1
                If a(i, j) <> "." Then flg = True
                Exit For
            Next
            If Not flg Then
                For i As Integer = 0 To H - 1
                    a(i, j) = ""
                Next
            End If
        Next

        For i As Integer = 0 To H - 1
            Dim s As String = ""
            For j As Integer = 0 To W - 1
                s &= (a(i, j))
            Next
            If s.Contains("#") Then
                WriteLine(s)
            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
