let rec foldn f a = function
  | 0 -> a
  | n -> foldn f (f a) (n - 1)

let () =
  let h, w = Scanf.scanf "%d %d\n" (fun h w -> h, w) in
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun i -> Scanf.scanf "%d " (fun a -> (i + 1, a))) in
  Array.fold_left (fun (acc, current, current_sum) (i, a) ->
    let c = Char.chr (i + Char.code '0') in
    if w <= current_sum + a then
      foldn (fun xs -> [String.make w c] :: xs)
        ((String.make (w - current_sum) c :: current) :: acc)
        ((current_sum + a) / w - 1), [String.make (current_sum + a - w) c], (current_sum + a - w) mod w
    else (acc, String.make a c :: current, a + current_sum)) ([], [], 0) as_
  |> (fun (acc, _, _) -> acc)
  |> List.fold_left (fun (acc, b) a -> ((if b then List.rev a else a) :: acc, not b)) ([], true)
  |> fst
  |> List.map (String.concat "")
  |> List.iter print_endline