#include <stdio.h>
#include <stdlib.h>
 
char cache[101];
 
typedef struct Node
{
    char data;
    struct Node * lchild,* rchild;
};
struct Node * root;
int cnt;
 
struct Node * Build_tree()
{
    struct Node * root;
    if(cache[cnt++] == '#') root = NULL;
    else
    {
        root = (struct Node *)malloc(sizeof(struct Node));
        root -> data = cache[cnt - 1];
        root -> lchild = Build_tree();
        root -> rchild = Build_tree();
    }
    return root;
}
void in_order(struct Node *root)
{
    if(root != NULL)
    {
        in_order(root -> lchild);
        printf("%c ",root -> data);
        in_order(root -> rchild);
    }
}
void clean(struct Node *root)
{
    if(root != NULL)
    {
        clean(root -> lchild);
        clean(root -> rchild);
        free(root);
    }
}
int main()
{
    int i;
    while(scanf("%s",cache) != EOF)
    {
        cnt = 0;
        root = Build_tree();
        in_order(root);
        clean(root);
        printf("\n");
    }
    return 0;
}
/**************************************************************
	Problem: 2215
	User: admin
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:1144 kb
****************************************************************/