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