#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
void dfs(int x,vector<int> V,int lim){
    if(x!=N)V.push_back(lim);
    if(x == 0){
        cout<<V[0];
        for(int i = 1;i < V.size();i++)cout<<" "<<V[i];
        cout<<endl;
        return;
    }
    for(int i = lim;i > 0;i--){
        if(x>=i){
            dfs(x-i,V,i);
        }
    }
}
int main(){

    vector<int> V;
    while(cin>>N,N)dfs(N,V,N);

    return 0;
}