local H, W = io.read("n", "n", "l")
local A = {}
for h=1,H do
  A[h] = {}
  for w=1,W do
    local a = io.read(1)
    A[h][w] = a
  end
  io.read("l")
end
local RH ={}
for h=1,H do
  local remove = true
  for w=1,W do
    if A[h][w] == '#' then
      remove = false
      break
    end
  end
  if remove then
    RH[h] = 1
  end
end
local RW = {}
for w=1,W do
  local remove = true
  for h=1,H do
    if A[h][w] == '#' then
      remove = false
      break
    end
  end
  if remove then
    RW[w] = 1
  end
end

for h=1,H do
  if not RH[h] then
    for w=1,W do
      if not RW[w] then
        io.write(A[h][w])
      end
    end
    print()
  end
end

