#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef vector<int> data;

vector<data> ans;

void make(data d, int n){
	if(n == 0){
		ans.push_back(d);
		return;
	}
	for(int i = 1;i <= n;i++){
		if(d.size() > 0 && i > d.back()) continue;
		data t = d;
		t.push_back(i);
		make(t, n - i);
	}
}

bool larger(const data &d1, const data &d2){
	for(int i = 0;i < d1.size() && i < d2.size();i++){
		if(d1[i] > d2[i]) return true;
		if(d1[i] < d2[i]) return false;
	}
	return false;
}

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		make(data(), n);
		sort(ans.begin(), ans.end(), larger);
		for(int i = 0;i < ans.size();i++){
			for(int j = 0;j < ans[i].size();j++){
				cout << ans[i][j];
				if(j != ans[i].size() - 1) cout << ' ';
			}
			cout << endl;
		}
		ans.clear();
	}
	
	return 0;
}