#include <stdio.h>
#include <string.h>
struct node
{
node *left,*right;
char letter;
node(){
left=NULL;
right=NULL;
letter=NULL;
}
}*root;
int num;
void buildtree(node *p,char *str) //建立二叉树
{
num++;
if(str[num]=='#')
p=NULL;
else
{
p->left=new node;
p->right=new node;
p->letter=str[num];
buildtree(p->left,str);
buildtree(p->right,str);
}
return ;
}
void preordervisit(node *p) //递归找先序遍历
{
if(p->letter!=NULL)
{
printf("%c",p->letter);
if(p->left!=NULL)
preordervisit(p->left);
if(p->right!=NULL)
preordervisit(p->right);
}
return ;
}
int main()
{
char str[105];
while(scanf("%s",&str)!=EOF)
{
num=-1;
root=new node;
buildtree(root,str);
preordervisit(root);
printf("\n");
}
return 0;
}