#!/usr/bin/env ruby
# coding: utf-8
h, _, k = ARGF.gets.split.map(&:to_i)
s = Array.new(h).map { ARGF.gets.chomp }

id = 0
t1 = s.map do |line|
  sp = line.split(/(#)/)
  if sp.size == 1
    []
  else
    id += 1
    sp[1] = 'x' # 誤魔化す
    sp.map do |i|
      if i == '#'
        id += 1
        [id]
      else
        Array.new(i.size, id)
      end
    end
  end.flat_map {|o|o}
end

ok1 = nil
ok2 = nil
t2 = t1.map do |tx|
  if tx == []
    ok2
  else
    ok1 = ok1 || tx
    ok2 = tx
    tx
  end
end.map do |tx|
  if tx == []
    ok1
  else
    tx
  end
end

t2.each do |tx|
  puts tx.map {|ty| sprintf("%3d", ty)}.join(' ')
end
