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

int[] data;

void solve(int n, int m) {
  if (n == 0) {
    for(uint i = 0; i < data.length; i++) write(format("%s%d", i ? " " : "", data[i]));
    writeln;
    return;
  }
  for(int i = min(n, m); i >= 1; i--) {
    data ~= i;
    solve(n - i, i);
    data.popBack;
  }
}

void main() {
  int n;
  while((n = readln.chomp.to!int) != 0) solve(n, n);
}