let k = Scanf.sscanf (read_line ()) "%d" @@ fun k -> k
let que = Queue.create ()


let rec loop que n =
  let v = Queue.pop que in
  if n = 1 then Printf.printf "%d\n" v
  else begin
    let t = v mod 10 in
    if t != 0 then Queue.add (v * 10 + t - 1) que;
    Queue.add (v * 10 + t) que;
    if t != 9 then Queue.add (v * 10 + t + 1) que;
    loop que (n - 1)
  end

let () =
  Array.iter (fun i -> Queue.add i que) @@ Array.init 9 (fun i -> i + 1);
  loop que k