local function range(b, e)
  local t = {}
  for i=1,e-b+1 do
    t[i] = b+i-1
  end
  return t
end
local function all(t, f)
  for k,v in pairs(t) do
    if not f(v) then
      return false
    end
  end
  return true
end

local function map(t, f)
  local nt = {}
  for k,v in pairs(t) do
    nt[k] = f(v)
  end
  return nt
end

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 rangeh = range(1,H)
local rangew = range(1,W)

RH = map(rangeh, function(h) return all(rangew, function(w) return A[h][w]=='.' end) end)
RW = map(rangew, function(w) return all(rangeh, function(h) return A[h][w]=='.' 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

