var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").map(Number);
arr.some(function(v){
   if(v==0)return true;
   var all=[];
   var loop=function(start,sum,arr){
      if(sum==v)all.push(arr);
      else{
         for(var i=start;i>=1;i--){
            if(arr.length==0)loop(start-1,sum+i,arr.concat(i));
            else if(arr[arr.length-1]>=i)loop(start-1,sum+i,arr.concat(i));
         }
      }
   }
   loop(v,0,[]);
   console.log(all.join("\n").replace(/\,/g," "));
});