local h, w = io.read("*n", "*n", "*l")
local t = {}
for i = 1, h do
  local s = io.read()
  for j = 1, w do
    t[(i - 1) * w + j] = s:sub(j, j) == "#"
  end
end
local omit_h = {}
local omit_w = {}
for i = 1, h do
  local f = true
  for j = 1, w do
    if t[(i - 1) * w + j] then
      f = false
      break
    end
  end
  if f then omit_h[i] = true end
end
for j = 1, w do
  local f = true
  for i = 1, h do
    if t[(i - 1) * w + j] then
      f = false
      break
    end
  end
  if f then omit_w[j] = true end
end
for i = 1, h do
  if not omit_h[i] then
    for j = 1, w do
      if not omit_w[j] then
        io.write(t[(i - 1) * w + j] and "#" or ".")
      end
    end
    io.write("\n")
  end
end
