#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

vector<vector<int> > ms;

void pf(int n,int max,vector<int> &a) {
    if (n == 0) {
        ms.push_back(a);
        return;
    }
    for (int i=min(n,max); i>0; --i) {
        a.push_back(i);
        pf(n-i, i, a);
        a.erase(a.end()-1);
    }
}

int n;

signed main() {
    while (true) {
        cin >> n;
        if (n == 0) break;

        ms.clear();

        vector<int> temp;
        pf(n, n, temp);

        rep(i,ms.size()) {
            rep(j,ms[i].size()) {
                cout << ms[i][j];
                if (j != ms[i].size() - 1) cout << " ";
            }
            cout << endl;
        }
    }
}