#include <iostream>
#include <vector>

using namespace std;

int main() {
	vector< vector< vector<int> > > data(31);
	for (int i = 1; i <= 30; i++) {
		vector<int> d;
		d.push_back(i);
		data[i].push_back(d);
		for (int j = i-1; j > 0; j--) {
			for (int k = 0; k < data[i-j].size(); k++) {
				d.clear();
				d.push_back(j);
				if (data[i-j][k][0] <= j) {
					d.insert(d.end(), data[i-j][k].begin(), data[i-j][k].end());
					data[i].push_back(d);
				}
			}
		}
	}
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		for (int i = 0; i < data[n].size(); i++) {
			cout << data[n][i][0];
			for (int j = 1; j < data[n][i].size(); j++) {
				cout << ' ' << data[n][i][j];
			}
			cout << endl;
		}
	}
	return 0;
}