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

tate = Array.new(H, false)
first_flag = false
H.times do |i|
  if !first_flag
    if s[i].any? {|m| m == '#'}
      first_flag = true
    end
    next
  end

  if s[i].any? {|m| m == '#'}
    tate[i] = true
  end
end

ans = Array.new(H) { Array.new(W, 0) }

i = 0
f = false
aaa = []
H.times do |h|
  if !f && h != H-1 && !tate[h+1]
    aaa.push(h)
    next
  end
  if f && h != 0 && !tate[h]
    W.times {|w| ans[h][w] = ans[h-1][w]}
    next
  end

  f = true
  i += 1
  first_flag2 = false
  W.times do |w|
    if !first_flag2
      if s[h][w] == '#'
        first_flag2 = true
      end
    else
      if s[h][w] == '#'
        i += 1
      end
    end
    ans[h][w] = i
  end
end

aaa.each do |aa|
  W.times {|w| ans[aa][w] = ans[aaa.size][w]}
end

ans.each do |an|
  puts an.join(' ')
end
