#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

H,W,K=get_i

$num=1
$ans=array(W,0,H)
def cut(l,r,s)
  pos=[]
  l.upto(r) do|i|
    W.times do|j|
        pos.push(j) if s[i][j]=="#"
    end
  end
  pos.sort!
  pos[0]=0
  pos.push(W)
  (pos.size-1).times do|j|
      pos[j].upto(max(pos[j+1]-1,pos[j])) do|k|
            l.upto(r) do|i|
              $ans[i][k]=$num
          end
      end
      $num+=1
  end
end

s=array(H)
h=[]
H.times do|i|
    s[i]=get_nsp
    h.push(i) if s[i].count("#")>0
end
h[0]=0
h.push(H)
#p h
(h.size-1).times do|i|
  cut(h[i],max(h[i+1]-1,h[i]),s)
end
H.times do|i|
    puts $ans[i].join(" ")
end