#include<cstdio>
#include<string>
using namespace std;
struct TreeNode{
char data;
TreeNode * leftChild;
TreeNode * rightChild;
};
TreeNode* RecursiveBulidTree(int &i, string str){
//返回的是本棵子树根节点的地址
char c = str[i];
++i;
if(c == '#'){
return NULL;
}
else{
TreeNode *pNewNode = new TreeNode;
pNewNode->data = c;
pNewNode->leftChild = RecursiveBulidTree(i,str);
pNewNode->rightChild = RecursiveBulidTree(i,str);
return pNewNode;
}
}
void InOrder(TreeNode *root){
if(root == NULL){
return;
}
else{
InOrder(root->leftChild);
printf("%c ", root->data);
InOrder(root->rightChild);
}
}
int main(){
//string str = "ab##cd#gf###e##";
char str[1000];
while (scanf("%s",str) != EOF){
int i = 0;
TreeNode * root = RecursiveBulidTree(i,str);
InOrder(root);
printf("\n");
}
}