(* 基本 *)
(* ocamlc str.cma main.ml でコンパイルできる *)
let () =
  let (h, w, k) = Scanf.sscanf (input_line stdin) "%d %d %d" (fun a b c -> (a, b, c)) in
  let a = Array.make_matrix h w ' ' in
  let b = Array.make_matrix h w 0 in
  let fst = ref (-1) in
  let last = ref (-1) in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      a.(i).(j) <- Scanf.scanf " %c" (fun x -> x);
      if a.(i).(j) = '#' then ((if !fst = (-1) then fst := i); last := i)
    done
  done;
  let tmp = ref 0 in
  for i = !fst to !last do
    let flag = ref true in
    for j = 0 to w - 1 do
      if a.(i).(j) = '#' then ((tmp := !tmp + 1);
                               flag := false);
      if !flag then b.(i).(j) <- !tmp + 1 else b.(i).(j) <- !tmp
    done;
    if !flag then
      for j = 0 to w - 1 do
        b.(i).(j) <- b.(i - 1).(j) 
      done
  done;
  
  if !fst <> 0 then
    for i = !fst - 1 downto 0 do
      for j = 0 to w - 1 do
        b.(i).(j) <- b.(i + 1).(j) 
      done
    done;
  
  if !last <> h then
    for i = !last + 1 to h - 1 do
      for j = 0 to w - 1 do
        b.(i).(j) <- b.(i - 1).(j) 
      done
    done;
  
  for i = 0 to h - 1 do
    for j = 0 to w - 2 do
      print_int b.(i).(j);
      print_char ' '
    done;
    print_int b.(i).(w - 1);
    print_newline ()
  done;
