#include <cstddef>
#include <iostream>
#include <cstring>

using namespace std;

string s;

struct Tnode{
    Tnode *left;
    Tnode *right;
    char val;
    Tnode(char x):val(x),left(NULL),right(NULL){}
};

Tnode* creatTree(int &i){//递归建树
    if(s[i]=='#') return NULL;
    Tnode *node=new Tnode(s[i]);
    node->left=creatTree(++i);
    node->right=creatTree(++i);
    return node;
}

void Inorder(Tnode *root){
    if(root==NULL) return;
    Inorder(root->left);
    cout<<root->val<<' ';
    Inorder(root->right);
}

int main() {
    while(cin>>s){
        int i=0;
        Tnode *root=creatTree(i);
        Inorder(root);
    }
}
// 64 位输出请用 printf("%lld")