#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int me[100000];
void solve(int x,int m,int n,int f){
  if(x>n) return;
  me[f]=m;
  if(n==x){
    for(int i=0;i<f;i++) printf("%d ",me[i]);
    printf("%d\n",me[f]);
    return;
  }
  for(int i=m;i>0;i--) solve(x+i,i,n,f+1);
}

int main(){
  while(1){
    cin >> n;
    if(n==0) break;
    for(int i=n;i>0;i--)
      solve(i,i,n,0);
  }
}