#include <stdio.h>
#include<stdlib.h>

struct TreeNode
{
    char val;
    struct TreeNode* left;
    struct TreeNode* right;
};


struct TreeNode* CreatTree(char* arr, int* sz)
{
    struct TreeNode* root = (struct TreeNode*)malloc(sizeof(struct TreeNode));
    if (arr[*sz] == '#')
    {
        return NULL;
    }
    root->val = arr[(*sz)++];
    root->left = CreatTree( arr, sz);
    (*sz)++;
    root->right = CreatTree(arr, sz);
    return root;
}


void PastTree(struct TreeNode* tmp)
{
    if (tmp == NULL)
    {
        //printf("# ");
        return;
    }
    PastTree(tmp->left);
    printf("%c ", tmp->val);
    PastTree(tmp->right);
}


int main()
{
    char arr[100] = "";
    scanf("%s", arr);
    int sz = 0;
    struct TreeNode* tmp = CreatTree(arr, &sz);

    PastTree(tmp);


    return 0;
}