#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <algorithm>
using namespacestd;
char str[55];//输入串
int len;
stack<int> stk;
char outs[55];//输出串
char outi = 0;//输出序列号
void oper(int p){
//可入栈
if(p<len){
stk.push(str[p]);
oper(p+1);
//恢复数据
stk.pop();
}
//可出栈
if(!stk.empty()){
char temp =stk.top();
outs[outi++] = temp;
stk.pop();
if(stk.empty() && p>=len){
for(int i=0;i<len;i++)printf("%c ",outs[i]);
printf("\n");
}
oper(p);
//恢复数据
stk.push(temp);
outi--;
}
}
int main(){
scanf("%s",str);
len =strlen(str);
stk.push(str[0]);
oper(1);
return0;
}