H, W, K = a = gets.chomp.split.map(&:to_i)
s = []
H.times do
  s.push(gets.chomp.split(''))
end

$ans = Array.new(H) { Array.new(W, 0) }
i = 1
ichi = []
H.times do |h|
  W.times do |w|
    if s[h][w] == '#'
      $ans[h][w] = i
      ichi.push([h, w])
      i += 1
    end
  end
end

$up = 0
def dfs_up(h, w, i)
  if h < 1 || $ans[h-1][w] != 0
    return
  end
  $up += 1
  $ans[h-1][w] = i
  dfs_up(h-1, w, i)
end

$ri = 0
def dfs_ri(h, w, i)
  if w >= W-1 || [*(h-$up..h)].any?{|hh| $ans[hh][w+1] != 0}
    return
  end
  $ri += 1
  [*(h-$up..h)].each {|hh| $ans[hh][w+1] = i}
  dfs_ri(h, w+1, i)
end

$down = 0
def dfs_down(h, w, i)
  if h >= H-1 || [*(w..w+$ri)].any?{|ww| $ans[h+1][ww] != 0}
    return
  end
  $down += 1
  [*(w..w+$ri)].each {|ww| $ans[h+1][ww] = i}
  dfs_down(h+1, w, i)
end

def dfs_le(h, w, i)
  if w < 1 || [*(h-$up..h+$down)].any?{|hh| $ans[hh][w-1] != 0}
    return
  end
  [*(h-$up..h+$down)].each {|hh| $ans[hh][w-1] = i}
  dfs_le(h, w-1, i)
end

ichi.each.with_index(1) do |hw, i|
  h, w = hw
  $up = 0
  dfs_up(h, w, i)

  $ri = 0
  dfs_ri(h, w, i)

  $down = 0
  dfs_down(h, w, i)

  dfs_le(h, w, i)
end

$ans.each do |ar|
  puts ar.join(' ')
end
