
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;

uint[][] show(uint n) {
  if (n == 1) return [[1]];
  uint half = n / 2;
  uint[][] res = [[n]];
  for(uint i = 1; i <= half; i++) {
    foreach(s; show(n - i)) res ~= ([i] ~ s).sort!((a, b) => a > b).array;
  }
  return res;
}

void main() {
  int n;
  while((n = readln.chomp.to!int) != 0) {
    uint[][] lists = show(n).sort!((a, b) => a.length < b.length).uniq.array;
    foreach(list; lists) {
      writeln(list.map!(to!(string)).join(" "));
    }
  }
}