let solve n =
  let rec solve n max =
    if n = 0 then [[]]
    else
      let rec loop i acc =
        if i > (min n max) then acc
        else
          let cdrs = solve (n - i) i in
          let acc = List.rev_append
                      (List.rev_map (fun cdr -> i :: cdr) cdrs)
                      acc in
          loop (i + 1) acc in
      loop 1 [] in
  solve n n

let () =
  let rec loop () =
    let n = int_of_string @@ read_line () in
    if n = 0 then ()
    else
      let answers = solve n in
      List.iter
        (fun seq ->
         print_endline @@ String.concat " " @@ List.map string_of_int seq)
        answers;
      loop () in
  loop ()