let input=readLine()!.characters.split(" ").map{Int(String($0))!}
let H=input[0],W=input[1]
let a=(0..<H).map{_ in readLine()!.characters.map{String($0)}}
var row=[Bool](count:H,repeatedValue:false)
var col=[Bool](count:W,repeatedValue:false)
for i in 0..<H{for j in 0..<W{if a[i][j]=="#"{row[i]=true;col[j]=true}}}
for i in 0..<H{if row[i]{for j in 0..<W{if col[j]{print(a[i][j],terminator: "")}};print()}}