local h, w, k = io.read("*n", "*n", "*n", "*l")
local map = {}
for i = 1, h do
  local s = io.read()
  for j = 1, w do
    map[(i - 1) * w + j] = s:sub(j, j) == "#"
  end
end
local hfound = false
local id = {}
local curid = 0
for i = 1, h * w do id[i] = 0 end
for i = 1, h do
  local wfound = false
  for j = 1, w do
    if map[(i - 1) * w + j] then
      curid = curid + 1
      if wfound then
        id[(i - 1) * w + j] = curid
      else
        for k = 1, j do
          id[(i - 1) * w + k] = curid
        end
        wfound = true
      end
    else
      id[(i - 1) * w + j] = curid
    end
  end
  if not wfound then
    if hfound then
      for j = 1, w do
        id[(i - 1) * w + j] = id[(i - 2) * w + j]
      end
    end
  else
    if not hfound then
      for k = 1, i - 1 do
        for j = 1, w do
          id[(k - 1) * w + j] = id[(i - 1) * w + j]
        end
      end
    end
    hfound = true
  end
end
for i = 1, h do
  for j = 1, w do
    io.write(id[(i - 1) * w + j])
    io.write(j == w and "\n" or " ")
  end
end
