#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct Tnode {
char data;
struct Tnode* lchild;
struct Tnode* rchild;
} Tnode;
void midorder(Tnode* root) {
if (root != NULL) {
midorder(root->lchild);
printf("%c ", root->data);
midorder(root->rchild);
} else {
return ;
}
}
int n = 0;
Tnode* maketree(char* x) {
static int n = 0;
if (x[n] == '#') {
n++;
// printf("%d",n);
return NULL;
}
Tnode* t = (Tnode*)calloc(1, sizeof(Tnode));
t->data = x[n];
n++;
// printf("%d",n);
t->lchild = maketree(x);
t->rchild = maketree(x);
return t;
}
int main() {
char x[101];
while (scanf("%s", &x) != EOF) {
Tnode* root;
root = maketree(x);
midorder(root);
}
}