Scanf.scanf "%d" (fun k ->
    let l = [ 1,  9; 1,  9;  1,  19;  2,  29;  3,  39;  4,  49;  5, 59;
              6, 69; 7, 79;  8,  89;  9,  99; 10, 109; 11, 109; 11, 99 ]
    in

    let proc ten s t acc =
        let rec loop i acc =
            if i > t then acc else
                loop (i + 1) ((i * ten + ten - 1) :: acc)
        in
        loop s acc
    in

    let rec loop ten acc = function
        | [] -> acc
        | (s, t) :: tl ->
                loop (ten * 10) (proc ten s t acc) tl
    in
    let r = Array.of_list (loop 1 [] l) in
    Array.sort compare r;
    for i = 0 to k - 1 do
        Printf.printf "%d\n" r.(i)
    done
)