#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
typedef struct bitree
{
char x;
struct bitree* left;
struct bitree* right;
}Bitree;
Bitree* creatBiTree(char *s,int *i)
{
if(s[*i]=='#')
{
return NULL;
}
Bitree *T = (Bitree*)malloc(sizeof(Bitree));
T->x = s[*i];
(*i)+=1;
T->left = creatBiTree(s,i);
(*i)+=1;
T->right = creatBiTree(s,i);
return T;
}
void inorder(Bitree* t)
{
if(t==NULL)
{
return;
}
inorder(t->left);
cout<<t->x<<' ';
inorder(t->right);
}
int main() {
char s[100];
scanf("%s",s);
int i=0;
Bitree *T =creatBiTree(s, &i);
inorder(T);
}