H, W, K = gets.chomp.split(" ").map(&:to_i)
S = []
ans = []
H.times{
  S << gets.chomp.split("")
  ans << Array.new(W, 0)
}

cnt = 1
(0...H).each{|i|
  (0...W).each{|j|
    if S[i][j] == '#' then
      ans[i][j] = cnt
      cnt += 1
    end
  }
}

(0...H).each{|i|
  wk = 0
  (0...W).each{|j|
    if ans[i][j] != 0 then
      wk = ans[i][j]
    else
      ans[i][j] = wk
    end
  }
  wk = 0
  (W-1).downto(0){|j|
    if ans[i][j] != 0 then
      wk = ans[i][j]
    else
      ans[i][j] = wk
    end
  }
}

(0...W).each{|j|
  wk = 0
  (0...H).each{|i|
    if ans[i][j] != 0 then
      wk = ans[i][j]
    else
      ans[i][j] = wk
    end
  }
  wk = 0
  (H-1).downto(0){|i|
    if ans[i][j] != 0 then
      wk = ans[i][j]
    else
      ans[i][j] = wk
    end
  }
}

(0...H).each{|i|
  (0...W).each{|j|
    printf("#{ans[i][j]} ")
  }
  printf("\n")
}
