#include <iostream>
using namespace std;
int dp[10000][31];
int Over(int k, int l)
{
	while(l>=1)
	{
		if(dp[k][l]>=2) break;
		else l--;
	}
	return l;
}
int main()
{
	while(1)
	{
		int n; cin >> n;
		if(!n) break;
		dp[0][0]=1; dp[0][1]=n;
		int s=1; int k=0;
		while(n!=1 && s>0)
		{
			int sum=0;
			for(int i=1;i<s;i++) dp[k+1][i]=dp[k][i], sum+=dp[k][i];
			dp[k+1][s]=dp[k][s]-1; sum+=dp[k+1][s];
			dp[k+1][s+1]=n-sum;
			while(dp[k+1][s+1]>dp[k+1][s])
			{
				dp[k+1][s+1]=dp[k+1][s]; sum+=dp[k+1][s+1];
				dp[k+1][s+2]=n-sum; s++;
			}
			dp[k+1][0]=s+1; k++;

			s=Over(k,dp[k][0]);
		}
		
		for(int j=0;j<=k;j++)
		{
			for(int i=1;i<=dp[j][0];i++)
			{
				if(i!=1) cout << ' ' ;	cout << dp[j][i] ;
			}
			cout << '\n' ;
		}
		
	}
}