h,w=io.read("*n","*n","*l")

grid={}
removerow={}
for i=1,h do
    s=io.read()
    grid[i]={}
    remove=true
    for j=1,w do
        grid[i][j]=s:sub(j,j)
        if grid[i][j]=="#" then
            remove=false
        end
    end
    if remove then
        table.insert(removerow,i)
    end
end

removecol={}
for j=1,w do
    remove=true
    for i=1,h do
        if grid[i][j]=="#" then
            remove=false
        end
    end
    if remove then
        table.insert(removecol,j)
    end
end

for i=#removerow,1,-1 do
    table.remove(grid,removerow[i])
end

for j=#removecol,1,-1 do
    for i,_ in pairs(grid) do
        table.remove(grid[i],removecol[j])
    end
end

for i,_ in pairs(grid) do
    print(table.concat(grid[i],""))
end