MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
h,w,k=gsmi
ans=[]
st_c=[]
first_str=nil
has=false
s=
  h.times.map do |i|
    str=gs
    c=str.count('#')
    st_c<< c
    if !has&&c>0
      idx=str.index('#')
      first_str=[i,idx]
      has=true
    end
    str
  end

cnt=1
first_str[0].upto(h-1) do |i|
  row=s[i]
  ar=[]
  if st_c[i]==0
    if i==0
      ar<<[cnt]*w
    else
      ar<<ans[-1]
    end
    ans<<ar
    next
  end

  r_cnt=0
  w.times do |j|
    r_cnt+=1
    if row[j]=='#'
      cnt+=1 unless i==first_str[0]&&j==first_str[1]
      ar<<[cnt]*r_cnt
      r_cnt=0
    end
  end
  ar<<[cnt]*r_cnt
  ans<<ar.flatten
end

# いちごがない最初の行を補正
ar=ans[0]
c = first_str[0]
c.times{ans.unshift ar}

ans.each{|r|puts r.join(" ")}