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