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

void main() {
  uint n;
  while((n = readln.chomp.to!uint) != 0) {
    uint[][][30] table;
    table[0] = [[]];
    table[1] = [[1]];

    for(int i = 2; i <= n; i++) {
      uint half = i / 2;
      table[i] ~= [[i]];
      for(uint j = 1; j <= half; j++) {
        foreach(s; table[i - j]) {
          table[i] ~= (s ~ [j]);
        }
      }
    }
    uint[][] items = table[n].map!((x) => x.sort!("a > b").array).array.sort!((a, b) => a.length < b.length).uniq.array;
    foreach(list; items) {
      writeln(list.map!(to!string).join(" "));
    }
  }
}