let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let (h, w, k) = Scanf.sscanf (read_line ()) "%d %d %d" @@ fun h w k -> (h, w, k)
let s = Array.init h @@ fun _ -> read_line () |> split_string |> Array.of_list

let row_count = Array.map (fun arr -> Array.fold_left (fun sum ch -> sum + if ch = "#" then 1 else 0) 0 arr) s

let fill_raw arr row v = 
  arr.(0) <- v + if s.(row).(0) = "#" then 1 else 0;
  for i = 1 to w - 1 do
    arr.(i) <- arr.(i - 1) + if s.(row).(i) = "#" then 1 else 0
  done;
  for i = w - 1 downto 0 do
    if arr.(i) = v then arr.(i) <- arr.(i + 1)
  done;
  arr.(w - 1)

let () =
  let ans = Array.init h @@ fun _ -> Array.make w 0 in
  let v = ref 0 in
  Array.iteri (fun i arr -> if row_count.(i) > 0 then v := fill_raw arr i !v) ans;
  for i = 1 to h - 1 do
    for j = 0 to w - 1 do
      if ans.(i).(j) = 0 then ans.(i).(j) <- ans.(i - 1).(j);
    done
  done;
  for i = h - 1 downto 0 do
    for j = 0 to w - 1 do
      if ans.(i).(j) = 0 then ans.(i).(j) <- ans.(i + 1).(j);
    done
  done;
  Array.iter (fun arr ->
    arr |> Array.map string_of_int |> Array.to_list |> String.concat " " |> print_endline
  ) ans