#include<iostream>
#include<cstdio>
#include<string>
 
using namespace std;

struct TreeNode{
    char data;
    TreeNode* lchild;
    TreeNode* rchild;
    TreeNode(char c): data(c),lchild(NULL),rchild(NULL){}
};

TreeNode* Build(int& pos,string str){
    char c=str[pos++];            //当前字符位置
    if(c=='#')                    //返回空树
        return NULL;
    TreeNode* root=new TreeNode(c);
    root->lchild=Build(pos,str);
    root->rchild=Build(pos,str);
    return root;
}

void InOrder(TreeNode* root){            //中序遍历
    if(root==NULL)
        return;
    InOrder(root->lchild);
    printf("%c ",root->data);
    InOrder(root->rchild);
    return;
}

int main(){
    string str;
    while(cin>>str){
        int pos=0;
        TreeNode* root=Build(pos,str);
        InOrder(root);
        printf("\n");
    }
    return 0;
}