#include<string>
#include<vector>
#include<sstream>
#include<iostream>
#include<algorithm>

using namespace std;

void part(int n,int k,string s)
{
	if(n==0){
		cout<<s.substr(0,s.length()-1)<<endl;
		return;
	}
	for(int i=min(n,k);i>=1;i--){
		stringstream ss;
		ss<<s<<i<<' ';
		part(n-i,i,ss.str());
	}
}

int main()
{
	for(int n;cin>>n,n;)	part(n,n,"");
	return 0;
}